aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/PostHead.astro
diff options
context:
space:
mode:
authoraman333nolawz <amananudhiu@gmail.com>2026-03-02 21:49:13 +0530
committeraman333nolawz <amananudhiu@gmail.com>2026-03-02 21:49:13 +0530
commitd41eff9eccf66644c4c60f53cb516bf079937a28 (patch)
tree248a0863a3181369f943d678ec4273911d35efac /src/components/PostHead.astro
Using astro-erudite for static site generation
Diffstat (limited to 'src/components/PostHead.astro')
-rw-r--r--src/components/PostHead.astro60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/components/PostHead.astro b/src/components/PostHead.astro
new file mode 100644
index 0000000..911b195
--- /dev/null
+++ b/src/components/PostHead.astro
@@ -0,0 +1,60 @@
+---
+import { SITE } from '@/consts'
+import { isSubpost } from '@/lib/data-utils'
+import type { CollectionEntry } from 'astro:content'
+
+interface Props {
+ post: CollectionEntry<'blog'>
+}
+
+const { post } = Astro.props
+
+const title = post.data.title || SITE.title
+const description = post.data.description || SITE.description
+const image = new URL('/static/1200x630.png', Astro.site)
+const author =
+ post.data.authors && post.data.authors.length > 0
+ ? post.data.authors.join(', ')
+ : SITE.author
+---
+
+<title>{`${title} | ${SITE.title}`}</title>
+<meta name="title" content={`${title} | ${SITE.title}`} />
+<meta name="description" content={description} />
+<link rel="canonical" href={SITE.href} />
+
+{isSubpost(post.id) && <meta name="robots" content="noindex" />}
+
+<meta property="og:title" content={title} />
+<meta property="og:description" content={description} />
+<meta
+ property="og:image"
+ content={post?.data?.image?.src
+ ? `${SITE.href}${post.data.image.src}`
+ : image}
+/>
+<meta property="og:image:alt" content={title} />
+<meta property="og:type" content="website" />
+<meta property="og:locale" content={SITE.locale} />
+<meta property="og:site_name" content={SITE.title} />
+<meta property="og:url" content={Astro.url} />
+<meta property="og:author" content={author} />
+
+<meta name="twitter:title" content={title} />
+<meta name="twitter:description" content={description} />
+<meta
+ property="twitter:image"
+ content={post?.data?.image?.src
+ ? `${SITE.href}${post.data.image.src}`
+ : image}
+/>
+<meta name="twitter:image:alt" content={title} />
+<meta name="twitter:card" content="summary_large_image" />
+<meta name="twitter:creator" content={author} />
+
+{
+ post?.data.tags &&
+ post.data.tags.map((tag: string) => {
+ return <meta property="article:tag" content={tag} />
+ })
+}