diff options
Diffstat (limited to 'code/frontpage/layouts/partials/head')
10 files changed, 395 insertions, 0 deletions
diff --git a/code/frontpage/layouts/partials/head/custom-head.html b/code/frontpage/layouts/partials/head/custom-head.html new file mode 100644 index 0000000..0c59d7f --- /dev/null +++ b/code/frontpage/layouts/partials/head/custom-head.html @@ -0,0 +1 @@ +<!-- Custom head --> diff --git a/code/frontpage/layouts/partials/head/favicons.html b/code/frontpage/layouts/partials/head/favicons.html new file mode 100644 index 0000000..93c5ed5 --- /dev/null +++ b/code/frontpage/layouts/partials/head/favicons.html @@ -0,0 +1,9 @@ +<meta name="theme-color" content="{{ $.Site.Params.themeColor }}"> +<link rel="icon" href="{{ "favicon.ico" | absURL }}" sizes="any"> +{{ if os.FileExists "static/favicon.svg" -}} + <link rel="icon" type="image/svg+xml" href="{{ "favicon.svg" | absURL }}"> +{{ end -}} +<link rel="apple-touch-icon" sizes="180x180" href="{{ "apple-touch-icon.png" | absURL }}"> +<link rel="icon" type="image/png" sizes="32x32" href="{{ "favicon-32x32.png" | absURL }}"> +<link rel="icon" type="image/png" sizes="16x16" href="{{ "favicon-16x16.png" | absURL }}"> +<link rel="manifest" crossorigin="use-credentials" href="{{ "site.webmanifest" | absURL }}"> diff --git a/code/frontpage/layouts/partials/head/head.html b/code/frontpage/layouts/partials/head/head.html new file mode 100644 index 0000000..12e2a8c --- /dev/null +++ b/code/frontpage/layouts/partials/head/head.html @@ -0,0 +1,11 @@ +<head> + <meta charset="utf-8"> + <meta http-equiv="x-ua-compatible" content="ie=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + {{ block "head/resource-hints" . }}{{ partial "head/resource-hints.html" . }}{{ end }} + {{ block "head/script-header" . }}{{ partial "head/script-header.html" . }}{{ end }} + {{ block "head/stylesheet" . }}{{ partial "head/stylesheet.html" . }}{{ end }} + {{ block "head/seo" . }}{{ partial "head/seo.html" . }}{{ end }} + {{ block "head/favicons" . }}{{ partial "head/favicons.html" . }}{{ end }} + {{ block "head/custom-head" . }}{{ partial "head/custom-head.html" . }}{{ end }} +</head> diff --git a/code/frontpage/layouts/partials/head/opengraph.html b/code/frontpage/layouts/partials/head/opengraph.html new file mode 100644 index 0000000..6127e82 --- /dev/null +++ b/code/frontpage/layouts/partials/head/opengraph.html @@ -0,0 +1,69 @@ +<meta property="og:locale" content="{{ .Site.Params.ogLocale }}"> +<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}"> +<meta property="og:title" content="{{ .Title }}"> +<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}"> +{{ if $.Scratch.Get "paginator" -}} + {{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Section" "blog" ) -}} + <meta property="og:url" content="{{ .Paginator.URL | absURL }}"> +{{ else -}} + <meta property="og:url" content="{{ .Permalink }}"> +{{ end -}} +{{ with .Site.Params.title -}} + <meta property="og:site_name" content="{{ . }}"> +{{ end -}} + +{{ $iso8601 := "2006-01-02T15:04:05-07:00" -}} +{{ if .IsPage -}} + {{ if not .PublishDate.IsZero -}} + <meta property="article:published_time" {{ .PublishDate.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> + {{ else if not .Date.IsZero -}} + <meta property="article:published_time" {{ .Date.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> + {{ end -}} + {{ if not .Lastmod.IsZero -}} + <meta property="article:modified_time" {{ .Lastmod.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> + {{ end -}} +{{ else -}} + {{ if not .Date.IsZero -}} + <meta property="og:updated_time" {{ .Lastmod.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}> + {{ end -}} +{{ end -}} + +{{ if eq .Kind "home" -}} + {{ .Scratch.Set "title" .Site.Params.titleHome -}} +{{ else -}} + {{ .Scratch.Set "title" .Title -}} +{{ end -}} + +{{ with $.Params.images -}} + {{ range first 6 . -}} + <meta property="og:image" content="{{ $.Permalink }}{{ . }}"> + {{ end -}} +{{ else -}} + {{ $images := $.Resources.ByType "image" -}} + {{ $featured := $images.GetMatch "*feature*" -}} + {{ if not $featured -}} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }} + {{ end -}} + {{ with $featured -}} + <meta property="og:image" content="{{ $featured.Permalink }}"/> + {{ else -}} + {{ with $.Site.Params.images -}} + <meta property="og:image" content="{{ index . 0 | absURL }}"/> + <meta property="og:image:alt" content="{{ $.Site.Params.title }}"> + {{ end -}} + {{ end -}} +{{ end -}} + +{{ with $.Site.Params.images -}} + {{ $.Scratch.Set "primaryImage" (index . 0 | absURL) -}} +{{ end -}} + +{{ with .Params.audio -}} + <meta property="og:audio" content="{{ . | absURL }}"> +{{ end -}} + +{{ with .Params.videos -}} + {{ range . -}} + <meta property="og:video" content="{{ . | absURL }}"> + {{ end -}} +{{ end -}} diff --git a/code/frontpage/layouts/partials/head/resource-hints.html b/code/frontpage/layouts/partials/head/resource-hints.html new file mode 100644 index 0000000..6ebcdeb --- /dev/null +++ b/code/frontpage/layouts/partials/head/resource-hints.html @@ -0,0 +1,4 @@ +{{ if .Site.Params.options.kaTex -}} +<link rel="preload" as="font" href="{{ " fonts/KaTeX_Main-Regular.woff2" | absURL }}" type="font/woff2" crossorigin> +<link rel="preload" as="font" href="{{ " fonts/KaTeX_Math-Italic.woff2" | absURL }}" type="font/woff2" crossorigin> +{{ end -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/script-header.html b/code/frontpage/layouts/partials/head/script-header.html new file mode 100644 index 0000000..38e5b5b --- /dev/null +++ b/code/frontpage/layouts/partials/head/script-header.html @@ -0,0 +1,8 @@ +{{ if .Site.Params.options.darkMode -}} + {{ $darkModeInit := resources.Get "js/darkmode-init.js" | js.Build | minify -}} + <script>{{ $darkModeInit.Content | safeJS }}</script> +{{ end -}} +{{- if and (.Site.Params.alert) (.Site.Params.alertDismissable) -}} + {{ $alertInit := resources.Get "js/alert-init.js" | js.Build | minify -}} + <script>{{ $alertInit.Content | safeJS }}</script> +{{- end -}}
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/seo.html b/code/frontpage/layouts/partials/head/seo.html new file mode 100644 index 0000000..ac31d72 --- /dev/null +++ b/code/frontpage/layouts/partials/head/seo.html @@ -0,0 +1,48 @@ +{{ if eq .Kind "404" -}} + <meta name="robots" content="noindex, follow"> +{{ else -}} + {{ with .Params.robots -}} + <meta name="robots" content="{{ . }}"> + {{ else -}} + <meta name="robots" content="index, follow"> + <meta name="googlebot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"> + <meta name="bingbot" content="index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"> + {{ end -}} +{{ end -}} + +{{ if .IsHome -}} + <title>{{ .Site.Params.title }} {{ .Site.Params.titleSeparator }} {{ .Site.Params.titleAddition }}</title> +{{ else -}} + <title>{{ .Title }} {{ .Site.Params.titleSeparator }} {{ .Site.Params.title }}</title> +{{ end -}} + +{{ with .Description -}} + <meta name="description" content="{{ . }}"> +{{ else -}} + {{ with .Summary | plainify -}} + <meta name="description" content="{{ . }}"> + {{ else -}} + <meta name="description" content="{{ .Site.Params.description }}"> + {{ end -}} +{{ end -}} + +{{ if $.Scratch.Get "paginator" }} + <link rel="canonical" href="{{ .Paginator.URL | absURL }}"> + {{ if .Paginator.HasPrev -}} + <link rel="prev" href="{{ .Paginator.Prev.URL | absURL }}"> + {{ end -}} + {{ if .Paginator.HasNext -}} + <link rel="next" href="{{ .Paginator.Next.URL | absURL }}"> + {{ end -}} +{{ else -}} + <link rel="canonical" href="{{ .Permalink }}"> +{{ end -}} + +{{ partial "head/opengraph.html" . }} +{{ partial "head/twitter_cards.html" . }} + +{{ range .AlternativeOutputFormats -}} + <link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}"> +{{ end -}} + +{{ partial "head/structured-data.html" . }} diff --git a/code/frontpage/layouts/partials/head/structured-data.html b/code/frontpage/layouts/partials/head/structured-data.html new file mode 100644 index 0000000..1f153a3 --- /dev/null +++ b/code/frontpage/layouts/partials/head/structured-data.html @@ -0,0 +1,210 @@ +{{ $baseURL := "/" | absURL -}} + +{{ $dot := . -}} +{{ $dot.Scratch.Set "path" "" -}} +{{ $dot.Scratch.Set "breadcrumb" slice -}} + +{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" -}} +{{ $.Scratch.Add "path" .Site.BaseURL -}} + +{{ $.Scratch.Add "breadcrumb" (slice (dict "url" .Site.BaseURL "name" "home" "position" 1 )) -}} + {{ range $index, $element := split $url "/" -}} + {{ $dot.Scratch.Add "path" $element -}} + {{ $.Scratch.Add "path" "/" -}} + {{ if ne $element "" -}} + {{ $.Scratch.Add "breadcrumb" (slice (dict "url" ($.Scratch.Get "path") "name" . "position" (add $index 2))) -}} + {{ end -}} +{{ end -}} + +<script type="application/ld+json"> +{ + "@context": "https://schema.org", + "@graph": [ + { + {{ if eq .Site.Params.schemaType "Organization" -}} + "@type": "Organization", + "@id": {{ print $baseURL "#/schema/organization/1" }}, + {{ else -}} + "@type": "Person", + "@id": {{ print $baseURL "#/schema/person/1" }}, + {{ end -}} + "name": "{{ .Site.Params.schemaName }}", + "url": {{ print $baseURL }}, + "sameAs": [ + {{ with .Site.Params.schemaTwitter -}} + {{ . }} + {{ end -}} + {{ with .Site.Params.schemaLinkedIn -}} + , {{ . }} + {{ end -}} + {{ with .Site.Params.schemaGitHub -}} + , {{ . }} + {{ end -}} + ], + {{ if eq .Site.Params.schemaType "Organization" -}} + "logo": { + "@type": "ImageObject", + "@id": {{ print $baseURL "#/schema/image/1"}}, + "url": {{ print $baseURL .Site.Params.schemaLogo }}, + "width": {{ .Site.Params.schemaLogoWidth }}, + "height": {{ .Site.Params.schemaLogoHeight }}, + "caption": "{{ .Site.Params.schemaName }}" + }, + "image": { + "@id": {{ print $baseURL "#/schema/image/1" }} + } + {{ else -}} + "image": { + "@type": "ImageObject", + "@id": {{ print $baseURL "#/schema/image/1"}}, + "url": {{ print $baseURL .Site.Params.schemaImage }}, + "width": {{ .Site.Params.schemaImageWidth }}, + "height": {{ .Site.Params.schemaImageHeight }}, + "caption": "{{ .Site.Params.schemaName }}" + } + {{ end -}} + }, + { + "@type": "WebSite", + "@id": {{ print $baseURL "#/schema/website/1" }}, + "url": {{ print $baseURL }}, + "name": "{{ .Site.Params.title }}", + "description": "{{ .Site.Params.description }}", + {{ if eq .Site.Params.schemaType "Organization" -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/organization/1" }} + } + {{ else -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/person/1" }} + } + {{ end -}} + }, + { + {{ if and (ne .Kind "taxonomy") (ne .Kind "term") -}} + "@type": "WebPage", + {{ else -}} + "@type": "CollectionPage", + {{ end -}} + "@id": {{ .Permalink }}, + "url": {{ .Permalink }}, + "name": "{{ .Title }}", + "description": "{{ .Description }}", + "isPartOf": { + "@id": {{ print $baseURL "#/schema/website/1" }} + }, + {{ if eq .Site.Params.schemaType "Organization" -}} + "about": { + "@id": {{ print $baseURL "#/schema/organization/1" }} + }, + {{ else -}} + "about": { + "@id": {{ print $baseURL "#/schema/person/1" }} + }, + {{ end -}} + "datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05CET" }}", + "dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}", + "breadcrumb": { + "@id": {{ print .Permalink "#/schema/breadcrumb/1" }} + }, + "primaryImageOfPage": { + "@id": {{ print .Permalink "#/schema/image/2" }} + }, + "inLanguage": "{{ .Site.Params.schemaLocale }}", + "potentialAction": [{ + "@type": "ReadAction", "target": [{{ .Permalink }}] + }] + }, + { + "@type": "BreadcrumbList", + "@id": {{ print .Permalink "#/schema/breadcrumb/1" }}, + "name": "Breadcrumbs", + "itemListElement": [{{ $list := $.Scratch.Get "breadcrumb" }}{{ $len := (len $list) }}{{ range $index, $element := $list }}{{ if ne .position 1 }},{{ end }}{ + "@type": "ListItem", + "position": {{ .position }}, + "item": { + {{ if ne (add $index 1) $len -}} + "@type": "WebPage", + "@id": {{ .url }}, + "url": {{ .url }}, + "name": "{{ .name | humanize | title }}" + {{ else -}} + "@id": {{ .url }} + {{ end -}} + } + }{{ end }}] + }, + + {{ if and (eq .Kind "page") (or (eq .Section "blog") (eq .Section "docs") (eq .Section "tutorial") (eq .Section "showcase")) -}} + { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "Article", + "@id": {{ print $baseURL "#/schema/article/1" }}, + "headline": "{{ .Title }}", + "description": "{{ .Description }}", + "isPartOf": { + "@id": {{ .Permalink }} + }, + "mainEntityOfPage": { + "@id": {{ .Permalink }} + }, + "datePublished": "{{ .PublishDate.Format "2006-01-02T15:04:05CET" }}", + "dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}", + "author": { + "@id": {{ print $baseURL "#/schema/person/2" }} + }, + {{ if eq .Site.Params.schemaType "Organization" -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/organization/1" }} + }, + {{ else -}} + "publisher": { + "@id": {{ print $baseURL "#/schema/person/1" }} + }, + {{ end -}} + "image": { + "@id": {{ print .Permalink "#/schema/image/2" }} + } + } + ] + }, + { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "Person", + "@id": {{ print $baseURL "#/schema/person/2" }}, + "name": {{ .Site.Params.schemaAuthor }}, + "sameAs": [ + {{ with .Site.Params.schemaAuthorTwitter -}} + {{ . }} + {{ end -}} + {{ with .Site.Params.schemaAuthorLinkedIn -}} + , {{ . }} + {{ end -}} + {{ with .Site.Params.schemaAuthorGitHub -}} + , {{ . }} + {{ end -}} + ] + } + ] + }, + {{ end -}} + { + "@context": "https://schema.org", + "@graph": [ + { + "@type": "ImageObject", + "@id": {{ print .Permalink "#/schema/image/2" }}, + "url": {{ $.Scratch.Get "primaryImage" }}, + "contentUrl": {{ $.Scratch.Get "primaryImage" }}, + "caption": "{{ .Title }}" + } + ] + } + + ] +} +</script>
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/stylesheet.html b/code/frontpage/layouts/partials/head/stylesheet.html new file mode 100644 index 0000000..4dc25c0 --- /dev/null +++ b/code/frontpage/layouts/partials/head/stylesheet.html @@ -0,0 +1,11 @@ +{{ if eq (hugo.Environment) "development" -}} + {{ $options := (dict "targetPath" "main.css" "enableSourceMap" true "includePaths" (slice "node_modules")) -}} + {{ $css := resources.Get "scss/app.scss" | toCSS $options -}} + <link rel="stylesheet" href="{{ $css.Permalink | relURL }}"> +{{ else -}} + {{ $options := (dict "targetPath" "main.css" "outputStyle" "compressed" "includePaths" (slice "node_modules")) -}} + {{ $css := resources.Get "scss/app.scss" | toCSS $options | postCSS (dict "config" "config/postcss.config.js") -}} + {{ $secureCSS := $css | resources.Fingerprint "sha512" -}} + <link rel="stylesheet" href="{{ $secureCSS.Permalink }}" integrity="{{ $secureCSS.Data.Integrity }}" crossorigin="anonymous"> +{{ end -}} +<noscript><style>img.lazyload { display: none; }</style></noscript>
\ No newline at end of file diff --git a/code/frontpage/layouts/partials/head/twitter_cards.html b/code/frontpage/layouts/partials/head/twitter_cards.html new file mode 100644 index 0000000..fdf581c --- /dev/null +++ b/code/frontpage/layouts/partials/head/twitter_cards.html @@ -0,0 +1,24 @@ +<meta name="twitter:card" content="summary_large_image"> +<meta name="twitter:site" content="{{ .Site.Params.twitterSite }}"> +<meta name="twitter:creator" content="{{ .Site.Params.twitterCreator }}"> +<meta name="twitter:title" content="{{ .Title }}"> +<meta name="twitter:description" content="{{ .Description }}"> +{{ with $.Params.images -}} + <meta name="twitter:image" content="{{ $.Permalink }}{{ index . 0 }}"> +{{ else -}} + {{ $images := $.Resources.ByType "image" -}} + {{ $featured := $images.GetMatch "*feature*" -}} + {{ if not $featured -}} + {{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" -}} + {{ end -}} + {{ with $featured -}} + <meta name="twitter:image" content="{{ $featured.Permalink }}"> + {{ else -}} + {{ with $.Site.Params.images -}} + <meta name="twitter:image" content="{{ index . 0 | absURL }}"> + {{ else -}} + <meta name="twitter:card" content="summary"> + {{ end -}} + {{ end -}} +{{ end -}} +<meta name="twitter:image:alt" content="{{ .Title }}">
\ No newline at end of file |
