mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-11 23:02:53 +01:00
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.
This commit is contained in:
@@ -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
|
||||
<meta property="og:url" content={Astro.url}>
|
||||
<meta property="og:title" content={pageTitle}>
|
||||
<meta property="og:description" content={description || pageTitle}>
|
||||
{setOGTypeArticle ? (
|
||||
<meta property="og:type" content="article" />
|
||||
) : (
|
||||
<meta property="og:type" content="website" />
|
||||
)}
|
||||
|
||||
<meta name="twitter:card" content="summary_large_image">
|
||||
<meta property="twitter:url" content={Astro.url}>
|
||||
|
||||
@@ -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
|
||||
---
|
||||
|
||||
<Layout title={title} banner={banner} description={description} lang={lang}>
|
||||
<Layout title={title} banner={banner} description={description} lang={lang} setOGTypeArticle={setOGTypeArticle}>
|
||||
<slot slot="head" name="head"></slot>
|
||||
<div id="top-row" class="z-50 pointer-events-none relative transition-all duration-700 max-w-[var(--page-width)] px-0 md:px-4 mx-auto" class:list={[""]}>
|
||||
<div id="navbar-wrapper" class="pointer-events-auto sticky top-0 transition-all">
|
||||
|
||||
Reference in New Issue
Block a user