From f0939088821f5865981359781877dd8b8bf66ea9 Mon Sep 17 00:00:00 2001 From: qhan Date: Sun, 3 Mar 2024 23:23:23 +0800 Subject: [PATCH] feat(site/blog): improve og style --- .../(web)/posts/[slug]/opengraph-image.tsx | 61 ++++++++++++++++--- site/blog/utils/seo.ts | 2 +- 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/site/blog/app/(web)/posts/[slug]/opengraph-image.tsx b/site/blog/app/(web)/posts/[slug]/opengraph-image.tsx index bcac7b2..95f1e04 100644 --- a/site/blog/app/(web)/posts/[slug]/opengraph-image.tsx +++ b/site/blog/app/(web)/posts/[slug]/opengraph-image.tsx @@ -8,32 +8,50 @@ export const alt = "Qhan W"; export const size = { width: 1200, height: 630 }; export const contentType = "image/png"; + + + + + export default async function Image({ params }: { params: { slug: string } }) { const post = await getPostBySlug(params.slug); + // Font + // const sacramentoRegular = fetch( + // new URL("./Sacramento-Regular.ttf", import.meta.url) + // ).then((res) => res.arrayBuffer()); + return new ImageResponse( (
{/* source: @/public/images/icon.svg */} - - + + @@ -44,24 +62,47 @@ export default async function Image({ params }: { params: { slug: string } }) {
{alt}
-
+
{post.meta.title}
), - { ...size } + { + ...size, + // fonts: [ + // { + // name: "Sacramento", + // data: await sacramentoRegular, + // style: "normal", + // weight: 400, + // }, + // ], + } ); } diff --git a/site/blog/utils/seo.ts b/site/blog/utils/seo.ts index b4ba223..b8c777f 100644 --- a/site/blog/utils/seo.ts +++ b/site/blog/utils/seo.ts @@ -33,7 +33,7 @@ export default function seo({ description, title }: SeoProps): Metadata { }, twitter: { card: "summary_large_image", - // site: siteMetadata.siteTitle, + site: siteMetadata.siteTitle, creator: siteMetadata?.social?.twitter, title: title, description: metaDescription,