Skip to content

Commit

Permalink
feat: custom meta images for albums
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed Dec 2, 2024
1 parent 82e23f3 commit 8dd26fe
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/files/albums/[slug].ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,30 @@ export const slug = defineAkteFiles<GlobalData, ["slugWithHash"]>().from({
}).join("\n")}
</article>`

const metaImageBase = doc.data.meta_image?.url
? { url: doc.data.meta_image?.url?.split("?")[0] }
: pictures[0]
const mask = prismic.asImageSrc(metaImageBase, { auto: ["format"], h: 800, pad: 40, bg: "#fffefe" })!
const metaImage = prismic.asImageSrc(metaImageBase, {
auto: undefined,
w: 1200,
h: 630,
fit: "crop",
exp: -40,
blur: 80,
duotone: ["131010", "fffefe"],
markW: 1080,
markH: 510,
markAlign: ["center", "middle"],
mark: mask,
})!

const meta = {
title: doc.data.meta_title || `${dateToUSFormat(pubDate)} ${title}`,
description: doc.data.meta_description,
image: {
openGraph: doc.data.meta_image?.url,
twitter: doc.data.meta_image?.twitter_variant?.url,
openGraph: metaImage,
twitter: metaImage,
},
}

Expand Down

0 comments on commit 8dd26fe

Please sign in to comment.