Skip to content

Commit 8dd26fe

Browse files
committed
feat: custom meta images for albums
1 parent 82e23f3 commit 8dd26fe

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/files/albums/[slug].ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,30 @@ export const slug = defineAkteFiles<GlobalData, ["slugWithHash"]>().from({
9696
}).join("\n")}
9797
</article>`
9898

99+
const metaImageBase = doc.data.meta_image?.url
100+
? { url: doc.data.meta_image?.url?.split("?")[0] }
101+
: pictures[0]
102+
const mask = prismic.asImageSrc(metaImageBase, { auto: ["format"], h: 800, pad: 40, bg: "#fffefe" })!
103+
const metaImage = prismic.asImageSrc(metaImageBase, {
104+
auto: undefined,
105+
w: 1200,
106+
h: 630,
107+
fit: "crop",
108+
exp: -40,
109+
blur: 80,
110+
duotone: ["131010", "fffefe"],
111+
markW: 1080,
112+
markH: 510,
113+
markAlign: ["center", "middle"],
114+
mark: mask,
115+
})!
116+
99117
const meta = {
100118
title: doc.data.meta_title || `${dateToUSFormat(pubDate)} ${title}`,
101119
description: doc.data.meta_description,
102120
image: {
103-
openGraph: doc.data.meta_image?.url,
104-
twitter: doc.data.meta_image?.twitter_variant?.url,
121+
openGraph: metaImage,
122+
twitter: metaImage,
105123
},
106124
}
107125

0 commit comments

Comments
 (0)