schema: add schema support in meta data #844

This commit is contained in:
Sören Weber 2024-04-24 21:20:11 +02:00
parent 9d01487e0d
commit ebe1dd13fe
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
4 changed files with 61 additions and 3 deletions

View file

@ -18,7 +18,7 @@ The Relearn theme is a fork of the great [Learn theme](https://github.com/matcor
- Usable offline, no external dependencies - Usable offline, no external dependencies
- [Usable from your local file system via `file://` protocol](https://mcshelby.github.io/hugo-theme-relearn/basics/customization#file-system) - [Usable from your local file system via `file://` protocol](https://mcshelby.github.io/hugo-theme-relearn/basics/customization#file-system)
- Support for the [VSCode Front Matter extension](https://github.com/estruyf/vscode-front-matter) for on-premise CMS capabilities - Support for the [VSCode Front Matter extension](https://github.com/estruyf/vscode-front-matter) for on-premise CMS capabilities
- [Support for Open Graph and Twitter Cards](https://mcshelby.github.io/hugo-theme-relearn/basics/customization#social-media-meta-tags) - [Support for Open Graph, Schema and Twitter Cards](https://mcshelby.github.io/hugo-theme-relearn/basics/customization#social-media-meta-tags)
- **Configurable theming and visuals** - **Configurable theming and visuals**
- [Configurable brand images](https://mcshelby.github.io/hugo-theme-relearn/basics/branding#change-the-logo) - [Configurable brand images](https://mcshelby.github.io/hugo-theme-relearn/basics/branding#change-the-logo)
- [Automatic switch for light/dark variant depending on your OS settings](https://mcshelby.github.io/hugo-theme-relearn/basics/branding#adjust-to-os-settings) - [Automatic switch for light/dark variant depending on your OS settings](https://mcshelby.github.io/hugo-theme-relearn/basics/branding#adjust-to-os-settings)

View file

@ -17,4 +17,5 @@
{{- $authorName := partialCached "authorname.hugo" . }} {{- $authorName := partialCached "authorname.hugo" . }}
<meta name="author" content="{{ $authorName }}"> <meta name="author" content="{{ $authorName }}">
{{- partial "twitter_cards.html" . }} {{- partial "twitter_cards.html" . }}
{{- partial "opengraph.html" . }} {{- partial "opengraph.html" . }}
{{- partial "schema.html" . }}

View file

@ -0,0 +1,57 @@
{{- /* based on Hugo 0.125.3 schema.html */}}
{{- with partial "pageHelper/title.hugo" (dict "page" . "fullyQualified" true "reverse" true) }}
<meta itemprop="name" content="{{ . }}">
{{- end }}
{{- with or .Description .Summary site.Params.Description }}
<meta itemprop="description" content="{{ . }}">
{{- end }}
{{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
{{- with .PublishDate }}
<meta itemprop="datePublished" {{ .Format $ISO8601 | printf "content=%q" | safeHTMLAttr }}>
{{- end }}
{{- with .Lastmod }}
<meta itemprop="dateModified" {{ .Format $ISO8601 | printf "content=%q" | safeHTMLAttr }}>
{{- end }}
{{- with .WordCount }}
<meta itemprop="wordCount" content="{{ . }}">
{{- end }}
{{- $images := partial "_funcs/get-page-images" . }}
{{- range first 6 $images }}
<meta itemprop="image" content="{{ .Permalink }}">
{{- end }}
{{- /*
Keywords precedence:
1. Use "keywords" term page titles.
2. Use "keywords" from front matter if "keywords" is not a taxonomy.
3. Use "tags" term page titles.
4. Use term page titles from all taxonomies.
*/}}
{{- $keywords := slice }}
{{- range .GetTerms "keywords" }}
{{- $keywords = $keywords | append .Title }}
{{- else }}
{{- with .Keywords }}
{{- $keywords = . }}
{{- else }}
{{- range .GetTerms "tags" }}
{{- $keywords = $keywords | append .Title }}
{{- else }}
{{- range $taxonomy, $_ := site.Taxonomies }}
{{- range $.GetTerms $taxonomy }}
{{- $keywords = $keywords | append .Title }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- with $keywords }}
<meta itemprop="keywords" content="{{ delimit . `,` }}">
{{- end }}

View file

@ -19,7 +19,7 @@ features = ["badges", "breadcrumbs", "boxes", "buttons",
"oas", "offline usable", "openapi", "open graph", "oas", "offline usable", "openapi", "open graph",
"print", "printable", "print", "printable",
"responsive", "rss", "rtl", "responsive", "rss", "rtl",
"search", "search page", "sidebar", "sitemap", "subtheme", "swagger", "swaggerui", "syntax highlighting", "schema", "search", "search page", "sidebar", "sitemap", "subtheme", "swagger", "swaggerui", "syntax highlighting",
"table of contents", "tab", "tabs", "tags", "taxonomy", "themeable", "themes", "toc", "topbar buttons", "twitter cards"] "table of contents", "tab", "tabs", "tags", "taxonomy", "themeable", "themes", "toc", "topbar buttons", "twitter cards"]
[module] [module]