From 7a022cc190a2036e85f32e150a54e4099ff672f3 Mon Sep 17 00:00:00 2001 From: "David V. Kimball" Date: Mon, 16 Sep 2024 22:35:58 -0700 Subject: [PATCH] feat: set `og:type` to `article` for posts (#183) * New prop setOGTypeArticle sets og:type to "article" for posts, and "website" for every other page. * Fixed error where I declared setOGTypeArticle twice. --- src/layouts/Layout.astro | 8 +++++++- src/layouts/MainGridLayout.astro | 5 +++-- src/pages/posts/[...slug].astro | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index da61680..4ce6ffe 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -22,9 +22,10 @@ interface Props { banner?: string description?: string lang?: string + setOGTypeArticle?: boolean } -let { title, banner, description, lang } = Astro.props +let { title, banner, description, lang, setOGTypeArticle } = Astro.props // apply a class to the body element to decide the height of the banner, only used for initial page load // Swup can update the body for each page visit, but it's after the page transition, causing a delay for banner height change @@ -82,6 +83,11 @@ const bannerOffset = bannerOffsetByPosition[siteConfig.banner.position || 'cente + {setOGTypeArticle ? ( + + ) : ( + + )} diff --git a/src/layouts/MainGridLayout.astro b/src/layouts/MainGridLayout.astro index 74c0268..dacd8b4 100644 --- a/src/layouts/MainGridLayout.astro +++ b/src/layouts/MainGridLayout.astro @@ -12,15 +12,16 @@ interface Props { banner?: string description?: string lang?: string + setOGTypeArticle?: boolean; } -const { title, banner, description, lang } = Astro.props +const { title, banner, description, lang, setOGTypeArticle } = Astro.props const hasBannerCredit = siteConfig.banner.enable && siteConfig.banner.credit.enable const hasBannerLink = !!siteConfig.banner.credit.url --- - +