Skip to content

Commit

Permalink
Merge pull request #112 from Yoshino-Yukitaro/develop
Browse files Browse the repository at this point in the history
feat: middlewareを書き直してみた
  • Loading branch information
Yoshino-Yukitaro authored Sep 16, 2024
2 parents 9b9cad0 + d96f8b0 commit 7d3c1cf
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions functions/post/_middleware.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,27 @@ const getFontData = async (url: string): Promise<ArrayBuffer> => {
return await fetch(resource[1]).then(async (res) => await res.arrayBuffer());
};

export const onRequest = async () => {
const notoSansJpUrl = `https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@600`;
const reggeaeOneUlr =
"https://fonts.googleapis.com/css2?family=Reggae+One&display=swap&text=ゆっきーの砂場";
const notoSansJpFontData = await getFontData(notoSansJpUrl);
const reggeaeOneFontData = await getFontData(reggeaeOneUlr);
return vercelOGPagesPlugin<OgImageProps>({
imagePathSuffix: "/og-image.png",
component: ({ ogTitle }) => {
return <OgImage ogTitle={ogTitle} />;
},
extractors: {
on: {
'meta[property="og:title"]': (props) => ({
element(element) {
props.ogTitle = element.getAttribute("content");
},
}),
},
export const onRequest = vercelOGPagesPlugin<OgImageProps>({
imagePathSuffix: "/og-image.png",
component: ({ ogTitle }) => {
return <OgImage ogTitle={ogTitle} />;
},
extractors: {
on: {
'meta[property="og:title"]': (props) => ({
element(element) {
props.ogTitle = element.getAttribute("content");
},
}),
},
options: {
},
options: async () => {
const notoSansJpUrl = `https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@600`;
const reggeaeOneUlr =
"https://fonts.googleapis.com/css2?family=Reggae+One&display=swap&text=ゆっきーの砂場";
const notoSansJpFontData = await getFontData(notoSansJpUrl);
const reggeaeOneFontData = await getFontData(reggeaeOneUlr);
return {
width: 800,
height: 400,
fonts: [
Expand All @@ -136,9 +136,9 @@ export const onRequest = async () => {
style: "normal",
},
],
},
autoInject: {
openGraph: true,
},
});
};
};
},
autoInject: {
openGraph: true,
},
});

0 comments on commit 7d3c1cf

Please sign in to comment.