From 8695df0533786f66a6509b53b2546ad0af63731d Mon Sep 17 00:00:00 2001 From: Denys Konovalov Date: Sun, 15 Sep 2024 22:26:56 +0200 Subject: [PATCH] fixes for new hugo versions --- .../data/abiturdurchschnitte.json | 0 {static => assets}/data/schuelerzahlen.json | 0 config.yml | 1 - content/chronikseiten/abiturdurchschnitte.md | 27 ++++------- layouts/partials/_funcs/get-page-images.html | 47 +++++++++++++++++++ layouts/partials/head.html | 4 +- layouts/partials/opengraph.html | 47 ------------------- layouts/partials/twitter.html | 29 ------------ layouts/schulchronik/single.html | 2 +- .../config/collections/settings-collection.js | 9 ---- static/admin/config/collections/stats.js | 4 +- 11 files changed, 62 insertions(+), 108 deletions(-) rename {static => assets}/data/abiturdurchschnitte.json (100%) rename {static => assets}/data/schuelerzahlen.json (100%) create mode 100644 layouts/partials/_funcs/get-page-images.html delete mode 100644 layouts/partials/opengraph.html delete mode 100644 layouts/partials/twitter.html diff --git a/static/data/abiturdurchschnitte.json b/assets/data/abiturdurchschnitte.json similarity index 100% rename from static/data/abiturdurchschnitte.json rename to assets/data/abiturdurchschnitte.json diff --git a/static/data/schuelerzahlen.json b/assets/data/schuelerzahlen.json similarity index 100% rename from static/data/schuelerzahlen.json rename to assets/data/schuelerzahlen.json diff --git a/config.yml b/config.yml index abe2cb57..a3a16752 100644 --- a/config.yml +++ b/config.yml @@ -1,6 +1,5 @@ baseURL: https://cantorgymnasium.de/ title: Georg-Cantor-Gymnasium -paginate: 8 summaryLength: "10" defaultContentLanguage: de enableEmoji: true diff --git a/content/chronikseiten/abiturdurchschnitte.md b/content/chronikseiten/abiturdurchschnitte.md index 5c53fbef..e197916c 100644 --- a/content/chronikseiten/abiturdurchschnitte.md +++ b/content/chronikseiten/abiturdurchschnitte.md @@ -182,31 +182,21 @@ aliases: right: 10, precision: 1, pieces: [ - { - gt: 0.9, - lte: 1.0, - color: "#005da9", - }, { gt: 1.0, lte: 1.5, - color: "#0b9834" + color: "#06511c", }, { gt: 1.5, lte: 2.0, - color: "#93CE07" + color: "#0b9834" }, { gt: 2.0, lte: 2.5, - color: "#FBDB0F" - }, - /*{ - gt: 2.0, - lte: 2.5, - color: "#FC7D02" - },*/ + color: "#10df4c" + } ], outOfRange: { color: "#999" @@ -225,16 +215,19 @@ aliases: }, data: [ { - yAxis: 1.4 + yAxis: 1.25 }, { - yAxis: 1.7 + yAxis: 1.5 + }, + { + yAxis: 1.75 }, { yAxis: 2.0 }, { - yAxis: 2.3 + yAxis: 2.25 } ] } diff --git a/layouts/partials/_funcs/get-page-images.html b/layouts/partials/_funcs/get-page-images.html new file mode 100644 index 00000000..caf456e1 --- /dev/null +++ b/layouts/partials/_funcs/get-page-images.html @@ -0,0 +1,47 @@ +{{- $imgs := slice }} +{{- $imgParams := slice .Params.image | append .Params.images }} +{{- $resources := .Resources.ByType "image" -}} +{{/* Find featured image resources if the images parameter is empty. */}} +{{- if or (not $imgParams) (eq ($imgParams | len) 0) }} + {{- $featured := $resources.GetMatch "*feature*" -}} + {{- if not $featured }}{{ $featured = $resources.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} + {{- with $featured }} + {{- $imgs = $imgs | append (dict + "Image" . + "RelPermalink" .RelPermalink + "Permalink" .Permalink) }} + {{- end }} +{{- end }} +{{/* Use the first one of site images as the fallback. */}} +{{- if and (not $imgParams) (not $imgs) }} + {{- with site.Params.images }} + {{- $imgParams = first 1 . }} + {{- end }} +{{- end }} +{{/* Parse page's images parameter. */}} +{{- range $imgParams }} + {{- $img := . }} + {{- $url := urls.Parse $img }} + {{- if eq $url.Scheme "" }} + {{/* Internal image. */}} + {{- with $resources.GetMatch $img -}} + {{/* Image resource. */}} + {{- $imgs = $imgs | append (dict + "Image" . + "RelPermalink" .RelPermalink + "Permalink" .Permalink) }} + {{- else }} + {{- $imgs = $imgs | append (dict + "RelPermalink" (relURL $img) + "Permalink" (absURL $img) + ) }} + {{- end }} + {{- else }} + {{/* External image */}} + {{- $imgs = $imgs | append (dict + "RelPermalink" $img + "Permalink" $img + ) }} + {{- end }} +{{- end }} +{{- return $imgs }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index a977e28f..22056129 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -51,6 +51,6 @@ }; - {{ partial "opengraph" . }} - {{ partial "twitter" . }} + {{ template "_internal/opengraph.html" . }} + {{ template "_internal/twitter_cards.html" . }} diff --git a/layouts/partials/opengraph.html b/layouts/partials/opengraph.html deleted file mode 100644 index 1b562917..00000000 --- a/layouts/partials/opengraph.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - -{{- with $.Params.images -}} -{{- range first 6 . }}{{ end -}} -{{- else -}} -{{- $images := $.Resources.ByType "image" -}} -{{- $featured := $images.GetMatch "*feature*" -}} -{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{- with $featured -}} - -{{- else -}} -{{- with $.Params.image -}} - -{{- else -}} -{{- with $.Site.Params.images }}{{ end -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{- if .IsPage }} -{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} - -{{ with .PublishDate }}{{ end }} -{{ with .Lastmod }}{{ end }} -{{- end -}} - -{{- with .Params.audio }}{{ end }} -{{- with .Params.locale }}{{ end }} -{{- with .Site.Params.title }}{{ end }} -{{- with .Params.videos }}{{- range . }} - -{{ end }}{{ end }} - -{{- /* If it is part of a series, link to related articles */}} -{{- $permalink := .Permalink }} -{{- $siteSeries := .Site.Taxonomies.series }} -{{- if $siteSeries }} -{{ with .Params.series }}{{- range $name := . }} - {{- $series := index $siteSeries ($name | urlize) }} - {{- range $page := first 6 $series.Pages }} - {{- if ne $page.Permalink $permalink }}{{ end }} - {{- end }} -{{ end }}{{ end }} -{{- end }} \ No newline at end of file diff --git a/layouts/partials/twitter.html b/layouts/partials/twitter.html deleted file mode 100644 index 317106e6..00000000 --- a/layouts/partials/twitter.html +++ /dev/null @@ -1,29 +0,0 @@ -{{- with $.Params.images -}} - - -{{ else -}} -{{- $images := $.Resources.ByType "image" -}} -{{- $featured := $images.GetMatch "*feature*" -}} -{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{- with $featured -}} - - -{{- else -}} -{{- with $.Params.image -}} - - -{{- else -}} -{{- with $.Site.Params.images -}} - - -{{ else -}} - -{{- end -}} -{{- end -}} -{{- end -}} -{{- end }} - - -{{ with .Site.Social.twitter -}} - -{{ end -}} \ No newline at end of file diff --git a/layouts/schulchronik/single.html b/layouts/schulchronik/single.html index 144e6b57..a657139e 100644 --- a/layouts/schulchronik/single.html +++ b/layouts/schulchronik/single.html @@ -27,7 +27,7 @@

{{ .Title }}

- {{ range (getJSON "static/data/abiturdurchschnitte.json").abiturdurchschnitte }} + {{ range (resources.Get "data/abiturdurchschnitte.json" | transform.Unmarshal).abiturdurchschnitte }} {{ if eq (string .jahr) $.Title }}Abiturdurchschnitt: {{ .schnitt }}{{ end }} {{ end }}
diff --git a/static/admin/config/collections/settings-collection.js b/static/admin/config/collections/settings-collection.js index 2f705901..1bfe7d81 100644 --- a/static/admin/config/collections/settings-collection.js +++ b/static/admin/config/collections/settings-collection.js @@ -376,15 +376,6 @@ const SettingsCollection = { required: true, }, Title(false), - { - name: "paginate", - label: "Anzahl der Seitenelemente", - widget: "number", - value_type: "int", - min: 1, - step: 1, - required: true, - }, { name: "summaryLength", label: "Länge von Zusammenfassungen (Zeichenanzahl)", diff --git a/static/admin/config/collections/stats.js b/static/admin/config/collections/stats.js index 9b265fd0..e179dab0 100644 --- a/static/admin/config/collections/stats.js +++ b/static/admin/config/collections/stats.js @@ -12,7 +12,7 @@ const StatsCollection = { { name: "abiturdurchschnitte", label: "Abiturdurchschnitte", - file: "static/data/abiturdurchschnitte.json", + file: "assets/data/abiturdurchschnitte.json", fields: [ { name: "abiturdurchschnitte", @@ -43,7 +43,7 @@ const StatsCollection = { { name: "schuelerzahlen", label: "Schülerzahlen", - file: "static/data/schuelerzahlen.json", + file: "assets/data/schuelerzahlen.json", fields: [ { name: "schuelerzahlen",