diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5ab6f9b3..b1a01774 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,6 +12,7 @@ repos: rev: v5.0.0 hooks: - id: check-added-large-files + args: [--maxkb=2048] - id: check-case-conflict - id: check-executables-have-shebangs - id: check-json diff --git a/assets/images/default.webp b/assets/images/default.webp new file mode 100644 index 00000000..f075ca92 Binary files /dev/null and b/assets/images/default.webp differ diff --git a/content/country/belgium/image.webp b/content/country/belgium/image.webp new file mode 100644 index 00000000..9c35f5c5 Binary files /dev/null and b/content/country/belgium/image.webp differ diff --git a/content/country/denmark/image.webp b/content/country/denmark/image.webp new file mode 100644 index 00000000..c7134624 Binary files /dev/null and b/content/country/denmark/image.webp differ diff --git a/content/country/netherlands/image.webp b/content/country/netherlands/image.webp new file mode 100644 index 00000000..670f2e03 Binary files /dev/null and b/content/country/netherlands/image.webp differ diff --git a/content/country/slovakia/image.webp b/content/country/slovakia/image.webp new file mode 100644 index 00000000..3f760a44 Binary files /dev/null and b/content/country/slovakia/image.webp differ diff --git a/content/news/image.webp b/content/news/image.webp deleted file mode 100644 index e05b8015..00000000 Binary files a/content/news/image.webp and /dev/null differ diff --git a/content/operator/dsb/image.webp b/content/operator/dsb/image.webp new file mode 100644 index 00000000..da7819cd Binary files /dev/null and b/content/operator/dsb/image.webp differ diff --git a/content/operator/eurostar/image.webp b/content/operator/eurostar/image.webp new file mode 100644 index 00000000..e1c416f1 Binary files /dev/null and b/content/operator/eurostar/image.webp differ diff --git a/content/operator/ns/image.webp b/content/operator/ns/image.webp new file mode 100644 index 00000000..85d466f5 Binary files /dev/null and b/content/operator/ns/image.webp differ diff --git a/content/operator/sncb/image.webp b/content/operator/sncb/image.webp new file mode 100644 index 00000000..be333cd3 Binary files /dev/null and b/content/operator/sncb/image.webp differ diff --git a/content/operator/zsr/image.webp b/content/operator/zsr/image.webp new file mode 100644 index 00000000..a8ec573e Binary files /dev/null and b/content/operator/zsr/image.webp differ diff --git a/layouts/_default/single.html b/layouts/_default/single.html index f0eeec43..015d522c 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,14 +1,14 @@ {{ define "main" }} -
-
-

{{ .Title }}

- {{ partial "updateDate.html" . }} -
+
+
+

{{ .Title }}

+ {{ partial "updateDate.html" . }} +
-
- {{ .Content }} -
+
+ {{ .Content }} +
- {{ partial "related.html" . }} -
+ {{ partial "related.html" . }} +
{{ end }} diff --git a/layouts/country/single.html b/layouts/country/single.html index 81da7e77..6ee6b956 100644 --- a/layouts/country/single.html +++ b/layouts/country/single.html @@ -38,6 +38,7 @@ + {{ partial "image" (partial "helper/contentImage" . ) }} diff --git a/layouts/operator/single.html b/layouts/operator/single.html index 2772de7d..025ad7c7 100644 --- a/layouts/operator/single.html +++ b/layouts/operator/single.html @@ -1,30 +1,31 @@ {{ define "main" }} - -
-
-
- {{ partial "sidemenu.html" . }} -
+ +
+
+
+ {{ partial "sidemenu.html" . }} +
-
-
-
-
- {{ $object := replace .Path (printf "/%s/" .Page.Type) "" }} - {{ $logo := resources.Get (printf "svg/logos/%s.svg" $object) }} - -

{{ .Title }}

+
+
+
+
+ {{ $object := replace .Path (printf "/%s/" .Page.Type) "" }} + {{ $logo := resources.Get (printf "svg/logos/%s.svg" $object) }} + +

{{ .Title }}

+
+ {{ partial "updateDate.html" . }}
- {{ partial "updateDate.html" . }} -
-
- {{- with .Content -}} - {{ . | replaceRE "()" (print `${1}${3}` (partial "icon" "link") ``) | safeHTML }} - {{- end -}} +
+ {{- with .Content -}} + {{ . | replaceRE "()" (print `${1}${3}` (partial "icon" "link") ``) | safeHTML }} + {{- end -}} +
+ {{ partial "image" (partial "helper/contentImage" . ) }}
-
-
+
{{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index d179e804..5f0fabc2 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,28 +1,4 @@ -{{ $metaDescription := "" }} -{{ if eq .Page.Type "country" }} - {{ $metaDescription = T "meta-description.country" }} -{{ else if eq .Page.Type "news" }} - {{ $metaDescription = T "meta-description.news" }} -{{ else if eq .Page.Type "news" }} - {{ $metaDescription = T "meta-description.news" }} -{{ else }} - {{ $metaDescription = .Description }} -{{ end }} - - - - - - - - - - - - - - - +{{ partial "headMeta.html" . }} {{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }} @@ -48,3 +24,23 @@ <link rel="icon" type="image/x-icon" href="/favicon.ico"> <link rel="apple-touch-icon" type="image/x-icon" href="/favicon.ico"> <link rel="mask-icon" type="image/x-icon" href="/favicon.ico"> +<link rel="canonical" href="{{ .Permalink }}"/> + +{{- $currentPage := . -}} +{{- range .Site.Languages -}} + {{- $lang := . -}} + {{- if eq $lang.Lang $currentPage.Lang -}} + <link rel="alternate" hreflang="{{ $lang.Lang }}" href="{{ $currentPage.Permalink }}" /> + {{- else -}} + {{- with $currentPage.Translations -}} + {{- range . -}} + {{- if eq .Lang $lang.Lang -}} + <link rel="alternate" hreflang="{{ .Lang }}" href="{{ .Permalink }}" /> + {{- end -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- end -}} +<link rel="alternate" hreflang="x-default" href="{{ .Site.BaseURL }}" /> + +{{ partial "structuredData.html" . }} diff --git a/layouts/partials/headMeta.html b/layouts/partials/headMeta.html new file mode 100644 index 00000000..026e00d1 --- /dev/null +++ b/layouts/partials/headMeta.html @@ -0,0 +1,26 @@ +{{ $metaDescription := "" }} <!-- Initialisierung der Variable --> +{{ if eq .Page.Type "country" }} + {{ $metaDescription = T "meta-description.country" }} +{{ else if eq .Page.Type "news" }} + {{ $metaDescription = T "meta-description.news" }} +{{ else if eq .Page.Type "news" }} + {{ $metaDescription = T "meta-description.news" }} +{{ else }} + {{ $metaDescription = .Description }} +{{ end }} + +<meta charset="utf-8" xmlns:og="http://www.w3.org/1999/xhtml" /> +<meta name="description" content="{{ $metaDescription }}" /> +<meta name="dc.relation" content="{{ .Site.BaseURL }}" /> +<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> +<meta name="theme-color" content="#BA3D12" /> +<meta property="og:url" content='{{ .Permalink }}'> +<meta property="og:site_name" content='{{ site.Title }}'> +<meta property="og:title" content='{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }}'> +<meta property="og:description" content="{{ $metaDescription }}" /> +<meta property="og:type" content='{{ if .IsPage }}article{{ else }}website{{ end }}'> +<meta property="og:image" content="{{ .Site.BaseURL }}og-image.jpg"> +<meta property="og:image:type" content="image/jpg"> +<meta property="og:image:width" content="1200"> +<meta property="og:image:height" content="630"> +<meta name="robots" content="index,follow"> diff --git a/layouts/partials/helper/contentImage.html b/layouts/partials/helper/contentImage.html new file mode 100644 index 00000000..fc355ac5 --- /dev/null +++ b/layouts/partials/helper/contentImage.html @@ -0,0 +1,6 @@ +{{ $contentImage := .Page.Resources.GetMatch "image.webp" }} +{{ if not $contentImage }} + {{ $contentImage = resources.Get "images/default.webp" }} +{{ end }} + +{{ return $contentImage }} diff --git a/layouts/partials/helper/dateHuman.html b/layouts/partials/helper/dateHuman.html new file mode 100644 index 00000000..e277b2c2 --- /dev/null +++ b/layouts/partials/helper/dateHuman.html @@ -0,0 +1,8 @@ +{{ $dateHuman := "" }} + +{{ if .Date }} + {{ $dateHuman = .Date | time.Format ":date_long" }} +{{ else if .GitInfo }} + {{ $dateHuman = .GitInfo.AuthorDate | time.Format ":date_long" }} +{{ end }} +{{ return $dateHuman }} diff --git a/layouts/partials/helper/dateMachine.html b/layouts/partials/helper/dateMachine.html new file mode 100644 index 00000000..961a9ae7 --- /dev/null +++ b/layouts/partials/helper/dateMachine.html @@ -0,0 +1,8 @@ +{{ $dateMachine := "" }} + +{{ if page.Date }} + {{ $dateMachine = page.Date | time.Format "2006-01-02T15:04:05-07:00" }} +{{ else if page.GitInfo }} + {{ $dateMachine = page.GitInfo.AuthorDate | time.Format "2006-01-02T15:04:05-07:00" }} +{{ end }} +{{ return $dateMachine }} diff --git a/layouts/partials/structuredData.html b/layouts/partials/structuredData.html new file mode 100644 index 00000000..2d8c8432 --- /dev/null +++ b/layouts/partials/structuredData.html @@ -0,0 +1,77 @@ +{{ $dateMachine := partial "helper/dateMachine" . }} +{{ $mainEntity := "" }} +{{ if (or (eq .Page.Type "country") (eq .Page.Type "operator")) }} + {{ $mainEntity = "Article" }} +{{ else if eq .Page.Type "news"}} + {{ $mainEntity = "NewsArticle" }} +{{ end }} + +{{ $image := (partial "helper/contentImage" .).Permalink }} + +<script type="application/ld+json">{ + "@context": "https://schema.org", + "@graph": [ + { + "@type": "WebSite", + "name": "{{ site.Title }}", + "url": {{ page.Site.BaseURL }} + }, + { + "@type": "WebPage", + "url": {{ .Permalink }}, + "name": "{{ .Title }}", + "publisher": { + "@type": "Organization", + "name": "FIP Guide", + "email": "nextstop@fipguide.org" + }, + {{- if not .IsHome }} + "breadcrumb": { + "@type": "BreadcrumbList", + "itemListElement": [ + {{- $i := 1 }} + {{- range page.Ancestors.Reverse }} + { + "@type": "ListItem", + "position": {{ $i }}, + "name": "{{ if .IsHome }}{{ site.Title }}{{ else }}{{ .Title }}{{ end }}", + "url": {{ .Permalink }}, + "item": {{ .Permalink }} + }, + {{- $i = add $i 1 -}} + {{ end }} + { + "@type": "ListItem", + "position": {{ $i }}, + "name": "{{ page.Title | safeJS }}", + "url": {{ page.Permalink }}, + "item": {{ page.Permalink }} + } + ] + }, + {{- end }} + {{- if $mainEntity }} + "mainEntity": { + "@type": "{{ $mainEntity }}", + "headline": "{{ page.Title }}", + "image": {{ $image }}, + "dateModified": {{ $dateMachine }}, + "author": { + "@type":"Organization", + "name": "FIP Guide", + "url": "https://www.fipguide.org/", + "email": "nextstop@fipguide.org" + } + }, + {{- end }} + "maintainer": { + "@type": "Organization", + "name": "FIP Guide", + "email": "nextstop@fipguide.org" + }, + "inLanguage": "{{ site.Language.LanguageCode }}", + "isAccessibleForFree": true + } + ] +} + </script> diff --git a/layouts/partials/teaser.html b/layouts/partials/teaser.html index 9958f4d2..a80a0e71 100644 --- a/layouts/partials/teaser.html +++ b/layouts/partials/teaser.html @@ -7,7 +7,7 @@ <a href="{{ $page.RelPermalink }}" class="m-teaser {{ if $listview }}m-teaser--listview row{{ else }}col-lg-4 col-md-6{{ end }} col-12"> - {{ $image := $page.Page.Resources.GetMatch "image.webp" }} + {{ $image := (partial "helper/contentImage" $page ) }} {{ if $image }} <div class="m-teaser__image{{ if $listview }} col-md-3 col-12{{ end }}"> {{ partialCached "image.html" $image $image }} diff --git a/layouts/partials/updateDate.html b/layouts/partials/updateDate.html index 9b43c120..95b19482 100644 --- a/layouts/partials/updateDate.html +++ b/layouts/partials/updateDate.html @@ -1,16 +1,13 @@ -{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }} -{{ $dateHuman := .Date | time.Format ":date_long" }} +{{ $dateMachine := partial "helper/dateMachine" . }} +{{ $dateHuman := partial "helper/dateHuman" . }} + +{{ if eq .Type "news" }} + <div class="updateDate" data-pagefind-ignore="all"> + <span>{{ T "updateDate"}}:</span> + <time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time> + </div> -{{ if .Date }} -<div class="updateDate" data-pagefind-ignore="all"> - {{ if ne .Type "news" }} - <span>{{ T "updateDate"}}:</span> - {{ end }} - <time datetime="{{ $dateMachine }}">{{ $dateHuman }}</time> -</div> {{ else if .GitInfo }} - {{ $dateMachine := .GitInfo.AuthorDate | time.Format "2006-01-02T15:04:05-07:00" }} - {{ $dateHuman := .GitInfo.AuthorDate | time.Format ":date_long" }} {{ $href := print .Site.Params.gitHubUrl "/commits/" .GitInfo.Hash "/content" .Path "/index." .Language ".md" }} <a href="{{ $href }}" diff --git a/layouts/robots.txt b/layouts/robots.txt index 89be35c0..0a6fc2c1 100644 --- a/layouts/robots.txt +++ b/layouts/robots.txt @@ -1,5 +1,17 @@ User-agent: * -{{ $imprintPage := site.GetPage "imprint" }}{{ if $imprintPage }}Disallow: {{ $imprintPage.RelPermalink }}{{ range $imprintPage.Translations }} -Disallow: {{ .RelPermalink }}{{ end }}{{ end }}{{ $imprintPage := site.GetPage "privacy" }}{{ if $imprintPage }} -Disallow: {{ $imprintPage.RelPermalink }}{{ range $imprintPage.Translations }} -Disallow: {{ .RelPermalink }}{{ end }}{{ end }} + +{{- $imprintPage := site.GetPage "imprint" }} +{{- if $imprintPage }} +Disallow: {{ $imprintPage.RelPermalink }} +{{- range $imprintPage.Translations }} +Disallow: {{ .RelPermalink }} +{{- end }} +{{- end }} + +{{- $privacyPage := site.GetPage "privacy" }} +{{- if $privacyPage }} +Disallow: {{ $privacyPage.RelPermalink }} +{{- range $privacyPage.Translations }} +Disallow: {{ .RelPermalink }} +{{- end }} +{{- end }}