@paroicms/server
Version:
The ParoiCMS server
15 lines • 652 B
JavaScript
import { getHandleOfFeaturedImage } from "@paroicms/public-server-lib";
export async function getFeaturedImageOf(renderingContext, { nodeId, documentType, }) {
if (documentType && !documentType.withFeaturedImage)
return;
const { siteContext, withAttachedData } = renderingContext;
const handle = getHandleOfFeaturedImage(nodeId);
const media = await siteContext.mediaStorage.getMedia({ handle, withAttachedData });
if (!media)
return;
if (media.kind !== "image") {
throw new Error(`media '${media.id}' should be an image (${handle})`);
}
return media;
}
//# sourceMappingURL=medias.helpers.js.map