From 15e3dedcee1d0830871ffc692143318a87646101 Mon Sep 17 00:00:00 2001 From: Christian Segundo Date: Thu, 25 Jul 2024 02:12:22 +0200 Subject: wip --- .../partials/templates/_funcs/get-page-images.html | 47 ++++++++ .../layouts/partials/templates/opengraph.html | 59 ++++++++++ .../layouts/partials/templates/schema_json.html | 124 +++++++++++++++++++++ .../layouts/partials/templates/twitter_cards.html | 38 +++++++ 4 files changed, 268 insertions(+) create mode 100644 _vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/_funcs/get-page-images.html create mode 100644 _vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/opengraph.html create mode 100644 _vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/schema_json.html create mode 100644 _vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/twitter_cards.html (limited to '_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates') diff --git a/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/_funcs/get-page-images.html b/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/_funcs/get-page-images.html new file mode 100644 index 0000000..268ceb4 --- /dev/null +++ b/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/_funcs/get-page-images.html @@ -0,0 +1,47 @@ +{{- $imgs := slice }} +{{- $imgParams := .Params.images }} +{{- $resources := .Resources.ByType "image" -}} +{{/* Find featured image resources if the images parameter is empty. */}} +{{- if not $imgParams }} + {{- $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/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/opengraph.html b/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/opengraph.html new file mode 100644 index 0000000..95f037c --- /dev/null +++ b/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/opengraph.html @@ -0,0 +1,59 @@ + + + + +{{- if .Params.cover.image -}} +{{- if (ne .Params.cover.relative true) }} + +{{- else}} + +{{- end}} +{{- else }} + +{{- $images := partial "partials/templates/_funcs/get-page-images" . -}} +{{- range first 6 $images }} + +{{ 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 }} + +{{- /* Deprecate site.Social.facebook_admin in favor of site.Params.social.facebook_admin */}} +{{- $facebookAdmin := "" }} +{{- with site.Params.social }} + {{- if reflect.IsMap . }} + {{- $facebookAdmin = .facebook_admin }} + {{- end }} +{{- else }} + {{- with site.Social.facebook_admin }} + {{- $facebookAdmin = . }} + {{- warnf "The social key in site configuration is deprecated. Use params.social.facebook_admin instead." }} + {{- end }} +{{- end }} + +{{- /* Facebook Page Admin ID for Domain Insights */}} +{{ with $facebookAdmin }}{{ end }} diff --git a/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/schema_json.html b/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/schema_json.html new file mode 100644 index 0000000..ed4d689 --- /dev/null +++ b/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/schema_json.html @@ -0,0 +1,124 @@ +{{ if .IsHome }} + +{{- else if (or .IsPage .IsSection) }} +{{/* BreadcrumbList */}} +{{- $url := replace .Parent.Permalink ( printf "%s" site.Home.Permalink) "" }} +{{- $lang_url := strings.TrimPrefix ( printf "%s/" .Lang) $url }} +{{- $bc_list := (split $lang_url "/")}} + +{{- $scratch := newScratch }} + +{{- if .IsPage }} + +{{- end }}{{/* .IsPage end */}} + +{{- end -}} diff --git a/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/twitter_cards.html b/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/twitter_cards.html new file mode 100644 index 0000000..46b0d04 --- /dev/null +++ b/_vendor/github.com/adityatelange/hugo-PaperMod/layouts/partials/templates/twitter_cards.html @@ -0,0 +1,38 @@ +{{- if .Params.cover.image -}} + +{{- if (ne $.Params.cover.relative true) }} + +{{- else }} + +{{- end}} +{{- else }} +{{- $images := partial "partials/templates/_funcs/get-page-images" . -}} +{{- with index $images 0 -}} + + +{{- else -}} + +{{- end -}} +{{- end }} + + +{{- /* Deprecate site.Social.twitter in favor of site.Params.social.twitter */}} +{{- $twitterSite := "" }} +{{- with site.Params.social }} + {{- if reflect.IsMap . }} + {{- $twitterSite = .twitter }} + {{- end }} +{{- else }} + {{- with site.Social.twitter }} + {{- $twitterSite = . }} + {{- warnf "The social key in site configuration is deprecated. Use params.social.twitter instead." }} + {{- end }} +{{- end }} + +{{- with $twitterSite }} + {{- $content := . }} + {{- if not (strings.HasPrefix . "@") }} + {{- $content = printf "@%v" $twitterSite }} + {{- end }} + +{{- end }} -- cgit v1.2.3