aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/PostHead.astro
blob: 911b19528e007de347a7eb44e869c9fbd0927cdb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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} />
    })
}