|
6 | 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
7 | 7 | <meta http-equiv="x-ua-compatible" content="ie=edge"> |
8 | 8 |
|
9 | | - <title>{{ block "title" . }}{{ .Site.Title }}{{ end }}</title> |
10 | | - <link rel="canonical" href="{{ .Site.BaseURL }}"> |
11 | | - <meta name="description" content="{{ block "description" . }}{{ .Site.Params.Description }}{{ end }}"> |
12 | | - |
13 | | - <meta property="og:type" content="website"> |
14 | | - <meta property="og:url" content="{{ .Site.BaseURL }}"> |
15 | | - <meta property="og:title" content="{{ .Site.Title }}"> |
16 | | - <meta property="og:description" content="{{ .Site.Params.Description }}"> |
17 | | - <meta property="og:image" content="{{ .Site.BaseURL }}screenshot.webp"> |
18 | | - <meta property="og:image:type" content="image/webp"> |
19 | | - <meta property="og:image:width" content="2592"> |
20 | | - <meta property="og:image:height" content="1191"> |
| 9 | + {{- $isBlogPost := and .IsPage (eq .Section "blog") -}} |
| 10 | + {{- $title := cond .IsHome .Site.Title .Title -}} |
| 11 | + {{- $rawDescription := "" -}} |
| 12 | + {{- if .IsHome -}} |
| 13 | + {{- $rawDescription = .Site.Params.Description -}} |
| 14 | + {{- else -}} |
| 15 | + {{- $rawDescription = .Description | default (.Summary | plainify) | default .Site.Params.Description -}} |
| 16 | + {{- end -}} |
| 17 | + {{- $description := trim (replaceRE "\\s+" " " $rawDescription) " " -}} |
| 18 | + {{- if gt (len $description) 200 -}} |
| 19 | + {{- $description = printf "%s…" (substr $description 0 199) -}} |
| 20 | + {{- end -}} |
| 21 | + {{- $url := .Permalink -}} |
| 22 | + {{- $image := printf "%sscreenshot.webp" .Site.BaseURL -}} |
| 23 | + {{- $imageWidth := 2592 -}} |
| 24 | + {{- $imageHeight := 1191 -}} |
| 25 | + {{- if $isBlogPost -}} |
| 26 | + {{- $cover := "" -}} |
| 27 | + {{- with .Resources.GetMatch "*.webp" -}}{{- $cover = . -}}{{- end -}} |
| 28 | + {{- if not $cover -}}{{- with .Resources.GetMatch "*.png" -}}{{- $cover = . -}}{{- end -}}{{- end -}} |
| 29 | + {{- with $cover -}} |
| 30 | + {{- $image = .Permalink -}} |
| 31 | + {{- $imageWidth = .Width -}} |
| 32 | + {{- $imageHeight = .Height -}} |
| 33 | + {{- end -}} |
| 34 | + {{- end -}} |
| 35 | + {{- $ogType := cond $isBlogPost "article" "website" -}} |
| 36 | + {{- $author := "" -}} |
| 37 | + {{- if $isBlogPost -}} |
| 38 | + {{- $author = index .Site.Data.authors (.Params.author | default "") -}} |
| 39 | + {{- end -}} |
| 40 | + |
| 41 | + <title>{{ $title }}</title> |
| 42 | + <link rel="canonical" href="{{ $url }}"> |
| 43 | + <meta name="description" content="{{ $description }}"> |
| 44 | + |
| 45 | + <meta property="og:type" content="{{ $ogType }}"> |
| 46 | + <meta property="og:url" content="{{ $url }}"> |
| 47 | + <meta property="og:title" content="{{ $title }}"> |
| 48 | + <meta property="og:description" content="{{ $description }}"> |
| 49 | + <meta property="og:image" content="{{ $image }}"> |
| 50 | + <meta property="og:image:width" content="{{ $imageWidth }}"> |
| 51 | + <meta property="og:image:height" content="{{ $imageHeight }}"> |
| 52 | + {{- if $isBlogPost }} |
| 53 | + <meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}"> |
| 54 | + {{- if and (not .Lastmod.IsZero) (ne .Date.Unix .Lastmod.Unix) }} |
| 55 | + <meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}"> |
| 56 | + {{- end }} |
| 57 | + {{- with $author }} |
| 58 | + <meta property="article:author" content="{{ .name }}"> |
| 59 | + {{- end }} |
| 60 | + <meta property="article:section" content="Blog"> |
| 61 | + {{- end }} |
21 | 62 |
|
22 | 63 | <meta name="twitter:card" content="summary_large_image"> |
23 | | - <meta name="twitter:title" content="{{ .Site.Title }}"> |
24 | | - <meta name="twitter:description" content="{{ .Site.Params.Description }}"> |
25 | | - <meta name="twitter:image" content="{{ .Site.BaseURL }}screenshot.webp"> |
| 64 | + <meta name="twitter:title" content="{{ $title }}"> |
| 65 | + <meta name="twitter:description" content="{{ $description }}"> |
| 66 | + <meta name="twitter:image" content="{{ $image }}"> |
26 | 67 |
|
27 | 68 | {{ $style := resources.Get "main.scss" | toCSS (dict "outputStyle" "compressed") }} |
28 | 69 | <link rel="stylesheet" href="{{ $style.Permalink }}"> |
|
32 | 73 | <link rel="manifest" href="{{ .Site.BaseURL }}manifest.webmanifest"> |
33 | 74 | <link rel="alternate" type="application/rss+xml" title="{{ .Site.Title }} Blog" href="{{ .Site.BaseURL }}blog/index.xml"> |
34 | 75 |
|
| 76 | + {{- if $isBlogPost }} |
| 77 | + <script type="application/ld+json"> |
| 78 | +{ |
| 79 | + "@context": "https://schema.org", |
| 80 | + "@type": "BlogPosting", |
| 81 | + "headline": {{ .Title | jsonify | safeJS }}, |
| 82 | + "description": {{ $description | jsonify | safeJS }}, |
| 83 | + "image": {{ $image | jsonify | safeJS }}, |
| 84 | + "datePublished": {{ .Date.Format "2006-01-02T15:04:05Z07:00" | jsonify | safeJS }}, |
| 85 | + "dateModified": {{ (.Lastmod | default .Date).Format "2006-01-02T15:04:05Z07:00" | jsonify | safeJS }}, |
| 86 | + "mainEntityOfPage": {{ $url | jsonify | safeJS }}, |
| 87 | + {{- with $author }} |
| 88 | + "author": { |
| 89 | + "@type": "Person", |
| 90 | + "name": {{ .name | jsonify | safeJS }}{{ with .url }}, |
| 91 | + "url": {{ . | jsonify | safeJS }}{{ end }} |
| 92 | + }, |
| 93 | + {{- end }} |
| 94 | + "publisher": { |
| 95 | + "@type": "Organization", |
| 96 | + "name": "Sourcemeta", |
| 97 | + "logo": { |
| 98 | + "@type": "ImageObject", |
| 99 | + "url": {{ (printf "%slogo.svg" .Site.BaseURL) | jsonify | safeJS }} |
| 100 | + } |
| 101 | + } |
| 102 | +} |
| 103 | + </script> |
| 104 | + {{- end }} |
| 105 | + |
35 | 106 | <script defer src="https://cdn.telemetrydeck.com/websdk/telemetrydeck.min.js" data-app-id="5BEC8971-2BEA-4D7C-A436-54EBDF4D6D93"></script> |
36 | 107 | </head> |
37 | 108 | <body> |
|
0 commit comments