From fb945ba3c1c1317bb70eba9d998cc6d690d077d5 Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Thu, 15 Oct 2020 10:21:33 +0530 Subject: [PATCH] json-schema: add support for Rich Results: Json schema for structured data (#36) * json-schema: init * sameAs can be set through .Site.Params.schema.sameAs * if it is not specified but social-icons exsists, we use social-icons for sameAs vars * .Site.Params.schema.sameAs overrides social-icons * publisherType can be changed via .Site.Params.schema.publisherType --- layouts/partials/head.html | 4 +- layouts/partials/templates/schema.html | 31 ---------- layouts/partials/templates/schema_json.html | 65 +++++++++++++++++++++ 3 files changed, 67 insertions(+), 33 deletions(-) delete mode 100644 layouts/partials/templates/schema.html create mode 100644 layouts/partials/templates/schema_json.html diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 55fa1328..1f786287 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -51,5 +51,5 @@ {{- template "_internal/google_analytics_async.html" . }} {{- template "partials/templates/opengraph.html" . }} {{- template "partials/templates/twitter_cards.html" . }} -{{- template "partials/templates/schema.html" . }} -{{- end }} \ No newline at end of file +{{- template "partials/templates/schema_json.html" . }} +{{- end }} diff --git a/layouts/partials/templates/schema.html b/layouts/partials/templates/schema.html deleted file mode 100644 index 6c032b66..00000000 --- a/layouts/partials/templates/schema.html +++ /dev/null @@ -1,31 +0,0 @@ - - - -{{- if .IsPage }}{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }}{{ if not .PublishDate.IsZero }} -{{ end }} -{{ if not .Lastmod.IsZero }}{{ end }} - -{{- if .Params.cover.image -}} -{{- if (ne .Params.cover.relative true) }} - -{{- else}} - -{{- end}} -{{- else }} -{{ 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 $.Site.Params.images -}} - -{{ end }}{{ end }}{{ end }} -{{- end }} - - - -{{- end }} diff --git a/layouts/partials/templates/schema_json.html b/layouts/partials/templates/schema_json.html new file mode 100644 index 00000000..a186603b --- /dev/null +++ b/layouts/partials/templates/schema_json.html @@ -0,0 +1,65 @@ +{{ if .IsHome }} + +{{- else if .IsPage }} + +{{ end }}