From 426446f77ef673689f9b2b074620595a79b3fb19 Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Wed, 13 Jul 2022 00:13:38 +0200 Subject: Provide ability to specify semantic page type in Front Matter --- layouts/partials/schema.org/article.html | 41 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'layouts/partials') diff --git a/layouts/partials/schema.org/article.html b/layouts/partials/schema.org/article.html index 05c8358..0c47dc8 100644 --- a/layouts/partials/schema.org/article.html +++ b/layouts/partials/schema.org/article.html @@ -1,6 +1,9 @@ {{- /* Get schema type. */}} {{- $schemaType := "Article" -}} -{{- if or (eq .Type "post") (eq .Type "posts") -}} + +{{- if (eq .Params.semanticType "about") -}} + {{- $schemaType = "AboutPage" -}} +{{- else if or (eq .Type "post") (eq .Type "posts") -}} {{- $schemaType = "BlogPosting" -}} {{- end -}} @@ -25,30 +28,28 @@ "datePublished": {{ .Date.Format "2006-01-02T15:04:05Z07:00" }}, "dateModified": {{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}, {{- if .Params.author }} - {{- $authorType := (printf "%T" .Params.author) }} + {{- $authorType := (printf "%T" .Params.author) -}} {{- if eq $authorType "string" }} - "author": { - "@type": "Person", - "name": {{ .Params.author }} - }, + "author": { + "@type": "Person", + "name": {{ .Params.author }} + }, {{- else if eq $authorType "[]string" }} - "author": [ - {{ range $i, $author := .Params.author }}{{ if $i }},{{ end }} - { - "@type": "Person", - "name": {{ $author }} - }{{ end }} - ], + "author": [ + {{ range $i, $author := .Params.author }}{{ if $i }},{{ end }} + { + "@type": "Person", + "name": {{ $author }} + }{{ end }} + ], {{- end }} {{- else }} {{- with site.Author.name }} - "author": { - "@type": "Person", - "name": {{ . }} - {{ with site.Author.twitter }}, - "url": "https://twitter.com/{{ . }}" - {{ end }} - }, + "author": { + "@type": "Person", + "name": {{ . }}{{ with site.Author.twitter }}, + "url": "https://twitter.com/{{ . }}"{{ end }} + }, {{- end }} {{- end }} "publisher": { -- cgit v1.2.3