summaryrefslogtreecommitdiff
path: root/themes/PaperMod/layouts/partials/templates
diff options
context:
space:
mode:
authorIndrajith K L2022-03-19 16:54:23 +0530
committerIndrajith K L2022-03-19 16:54:23 +0530
commit29fcd231e3da9b33c237886f3c1bb30a557ad641 (patch)
tree8eba56550b35938e7c445c9ed6d9005c14036666 /themes/PaperMod/layouts/partials/templates
downloadexperimentsofindrajith-29fcd231e3da9b33c237886f3c1bb30a557ad641.tar.gz
experimentsofindrajith-29fcd231e3da9b33c237886f3c1bb30a557ad641.tar.bz2
experimentsofindrajith-29fcd231e3da9b33c237886f3c1bb30a557ad641.zip
Initial Commit
Diffstat (limited to 'themes/PaperMod/layouts/partials/templates')
-rw-r--r--themes/PaperMod/layouts/partials/templates/opengraph.html52
-rw-r--r--themes/PaperMod/layouts/partials/templates/schema_json.html119
-rw-r--r--themes/PaperMod/layouts/partials/templates/twitter_cards.html33
3 files changed, 204 insertions, 0 deletions
diff --git a/themes/PaperMod/layouts/partials/templates/opengraph.html b/themes/PaperMod/layouts/partials/templates/opengraph.html
new file mode 100644
index 0000000..9bbd90b
--- /dev/null
+++ b/themes/PaperMod/layouts/partials/templates/opengraph.html
@@ -0,0 +1,52 @@
+<meta property="og:title" content="{{ .Title }}" />
+<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
+<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
+<meta property="og:url" content="{{ .Permalink }}" />
+{{- if .Params.cover.image -}}
+{{- if (ne .Params.cover.relative true) }}
+<meta property="og:image" content="{{ .Params.cover.image | absURL }}" />
+{{- else}}
+<meta property="og:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
+{{- end}}
+{{- else }}
+
+{{- with $.Params.images -}}
+{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}}
+{{- else -}}
+{{- $images := $.Resources.ByType "image" -}}
+{{- $featured := $images.GetMatch "*feature*" -}}
+{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
+{{- with $featured -}}
+<meta property="og:image" content="{{ $featured.Permalink }}"/>
+{{- else -}}
+{{- with $.Site.Params.images }}<meta property="og:image" content="{{ index . 0 | absURL }}"/>{{ end -}}
+{{- end -}}
+{{- end -}}
+{{- end }}
+
+{{- if .IsPage }}
+{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
+<meta property="article:section" content="{{ .Section }}" />
+{{ with .PublishDate }}<meta property="article:published_time" content="{{ .Format $iso8601 }}" />{{ end }}
+{{ with .Lastmod }}<meta property="article:modified_time" content="{{ .Format $iso8601 }}" />{{ end }}
+{{- end -}}
+
+{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
+{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
+{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
+{{- with .Params.videos }}{{- range . }}
+<meta property="og:video" content="{{ . | absURL }}" />
+{{ end }}{{ end }}
+
+{{- /* If it is part of a series, link to related articles */}}
+{{- $permalink := .Permalink }}
+{{- $siteSeries := .Site.Taxonomies.series }}
+{{ with .Params.series }}{{- range $name := . }}
+ {{- $series := index $siteSeries ($name | urlize) }}
+ {{- range $page := first 6 $series.Pages }}
+ {{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}" />{{ end }}
+ {{- end }}
+{{ end }}{{ end }}
+
+{{- /* Facebook Page Admin ID for Domain Insights */}}
+{{- with .Site.Social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
diff --git a/themes/PaperMod/layouts/partials/templates/schema_json.html b/themes/PaperMod/layouts/partials/templates/schema_json.html
new file mode 100644
index 0000000..5cf3857
--- /dev/null
+++ b/themes/PaperMod/layouts/partials/templates/schema_json.html
@@ -0,0 +1,119 @@
+{{ if .IsHome }}
+<script type="application/ld+json">
+{
+ "@context": "https://schema.org",
+ "@type": "{{- ( .Site.Params.schema.publisherType | default "Organization") | title -}}",
+ "name": {{ .Site.Title }},
+ "url": {{ .Site.BaseURL }},
+ "description": {{ .Site.Params.description | plainify | truncate 180 | safeHTML }},
+ "thumbnailUrl": {{ .Site.Params.assets.favicon | default "favicon.ico" | absURL }},
+ "sameAs": [
+ {{- if .Site.Params.schema.sameAs }}
+ {{ range $i, $e := .Site.Params.schema.sameAs }}{{ if $i }}, {{ end }}{{ trim $e " " }}{{ end }}
+ {{- else}}
+ {{ range $i, $e := .Site.Params.SocialIcons }}{{ if $i }}, {{ end }}{{ trim $e.url " " }}{{ end }}
+ {{- end}}
+ ]
+}
+</script>
+{{- else if (or .IsPage .IsSection) }}
+{{/* BreadcrumbList */}}
+{{- $url := replace .Parent.Permalink ( printf "%s" .Site.BaseURL) "" }}
+{{- $lang_url := strings.TrimPrefix ( printf "%s/" .Lang) $url }}
+{{- $bc_list := (split $lang_url "/")}}
+
+{{- $scratch := newScratch }}
+<script type="application/ld+json">
+{
+ "@context": "https://schema.org",
+ "@type": "BreadcrumbList",
+ "itemListElement": [
+ {{- range $index, $element := $bc_list }}
+
+ {{- $scratch.Add "path" (printf "%s/" $element ) | safeJS }}
+ {{- $bc_pg := $.Site.GetPage ($scratch.Get "path") -}}
+
+ {{- if (and ($bc_pg) (gt (len . ) 0))}}
+ {{- if (and $index)}}, {{end }}
+ {
+ "@type": "ListItem",
+ "position": {{ add 1 $index }},
+ "name": {{ $bc_pg.Name }},
+ "item": {{ $bc_pg.Permalink | safeHTML }}
+ }
+ {{- end }}
+
+ {{- end }}
+ {{- /* self-page addition */ -}}
+ {{- if (ge (len $bc_list) 2) }}, {{end }}
+ {
+ "@type": "ListItem",
+ "position": {{len $bc_list}},
+ "name": {{ .Name }},
+ "item": {{ .Permalink | safeHTML }}
+ }
+ ]
+}
+</script>
+{{- if .IsPage }}
+<script type="application/ld+json">
+{
+ "@context": "https://schema.org",
+ "@type": "BlogPosting",
+ "headline": {{ .Title | plainify}},
+ "name": "{{ .Title | plainify }}",
+ "description": {{ with .Description | plainify }}{{ . }}{{ else }}{{ .Summary | plainify }}{{ end -}},
+ "keywords": [
+ {{- if .Params.keywords }}
+ {{ range $i, $e := .Params.keywords }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}
+ {{- else }}
+ {{ range $i, $e := .Params.tags }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}
+ {{- end }}
+ ],
+ "articleBody": {{ .Content | safeJS | htmlUnescape | plainify }},
+ "wordCount" : "{{ .WordCount }}",
+ "inLanguage": {{ .Language.Lang | default "en-us" }},
+ {{ if .Params.cover.image -}}
+ "image":
+ {{- if (ne .Params.cover.relative true) -}}
+ {{ .Params.cover.image | absURL }},
+ {{- else -}}
+ {{ (path.Join .RelPermalink .Params.cover.image ) | absURL }},
+ {{- end}}
+ {{- end -}}
+ "datePublished": {{ .PublishDate }},
+ "dateModified": {{ .Lastmod }},
+ {{- with (.Params.author | default .Site.Params.author) }}
+ "author":
+ {{- if (or (eq (printf "%T" .) "[]string") (eq (printf "%T" .) "[]interface {}")) -}}
+ [{{- range $i, $v := . -}}
+ {{- if $i }}, {{end -}}
+ {
+ "@type": "Person",
+ "name": {{ $v }}
+ }
+ {{- end }}],
+ {{- else -}}
+ {
+ "@type": "Person",
+ "name": {{ . }}
+ },
+ {{- end -}}
+ {{- end }}
+ "mainEntityOfPage": {
+ "@type": "WebPage",
+ "@id": {{ .Permalink | safeHTML }}
+ },
+ "publisher": {
+ "@type": "{{- ( .Site.Params.schema.publisherType | default "Organization") | title -}}",
+ "name": {{ .Site.Title }},
+ "logo": {
+ "@type": "ImageObject",
+ "url": {{ .Site.Params.assets.favicon | default "favicon.ico" | absURL }}
+ }
+ }
+}
+</script>
+{{- end }}{{/* .IsPage end */}}
+
+{{- end -}}
diff --git a/themes/PaperMod/layouts/partials/templates/twitter_cards.html b/themes/PaperMod/layouts/partials/templates/twitter_cards.html
new file mode 100644
index 0000000..02270de
--- /dev/null
+++ b/themes/PaperMod/layouts/partials/templates/twitter_cards.html
@@ -0,0 +1,33 @@
+{{- if .Params.cover.image -}}
+<meta name="twitter:card" content="summary_large_image" />
+{{- if (ne $.Params.cover.relative true) }}
+<meta name="twitter:image" content="{{ .Params.cover.image | absURL }}" />
+{{- else }}
+<meta name="twitter:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
+{{- end}}
+{{- else }}
+{{- with $.Params.images -}}
+<meta name="twitter:card" content="summary_large_image"/>
+<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
+{{ else -}}
+{{- $images := $.Resources.ByType "image" -}}
+{{- $featured := $images.GetMatch "*feature*" -}}
+{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
+{{- with $featured -}}
+<meta name="twitter:card" content="summary_large_image"/>
+<meta name="twitter:image" content="{{ $featured.Permalink }}"/>
+{{- else -}}
+{{- with $.Site.Params.images -}}
+<meta name="twitter:card" content="summary_large_image"/>
+<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
+{{ else -}}
+<meta name="twitter:card" content="summary"/>
+{{- end -}}
+{{- end -}}
+{{- end }}
+{{- end }}
+<meta name="twitter:title" content="{{ .Title }}"/>
+<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
+{{ with .Site.Social.twitter -}}
+<meta name="twitter:site" content="@{{ . }}"/>
+{{ end -}}