mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-06 08:13:41 +00:00
refactor: convert Event Microdata to JSONLD
Requires further work to add support for full semantic event address. Forms part of the transition from Microdata to JSON-LD. See #413
This commit is contained in:
1 parent
5d590b64f6
commit
1b2e20cc2a
4 files changed
+81
-26
No files matched your search
@@ -23,27 +23,27 @@
|
||||
{{ end }}
|
||||
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": {{$schema}},
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": {{$page.Permalink}}
|
||||
},
|
||||
"headline": {{$page.Title}},
|
||||
{{ if $featured_image }}
|
||||
"image": [
|
||||
{{$featured_image.Permalink}}
|
||||
],
|
||||
{{end}}
|
||||
"datePublished": {{ $page.PublishDate.Format "2006-01-02T15:04:05Z07:00" }},
|
||||
"dateModified": {{ $page.Lastmod.Format "2006-01-02T15:04:05Z07:00" }},
|
||||
{{with $author}}
|
||||
"author": {
|
||||
"@type": "Person",
|
||||
"name": {{.}}
|
||||
},
|
||||
{{end}}
|
||||
"description": {{$summary}}
|
||||
}
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": {{$schema}},
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": {{$page.Permalink}}
|
||||
},
|
||||
"headline": {{$page.Title}},
|
||||
{{ if $featured_image }}
|
||||
"image": [
|
||||
{{$featured_image.Permalink}}
|
||||
],
|
||||
{{end}}
|
||||
"datePublished": {{ $page.PublishDate.Format "2006-01-02T15:04:05Z07:00" }},
|
||||
"dateModified": {{ $page.Lastmod.Format "2006-01-02T15:04:05Z07:00" }},
|
||||
{{with $author}}
|
||||
"author": {
|
||||
"@type": "Person",
|
||||
"name": {{.}}
|
||||
},
|
||||
{{end}}
|
||||
"description": {{$summary}}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,51 @@
|
||||
{{ $page := .page }}
|
||||
{{ $summary := .summary }}
|
||||
{{ $featured_image := ($page.Resources.ByType "image").GetMatch "*featured*" }}
|
||||
|
||||
{{/* Get author name. */}}
|
||||
{{ $author_username := "" }}
|
||||
{{ if and (not $page.Params.authors) ($page.Scratch.Get "superuser_username") }}
|
||||
{{ $author_username = $page.Scratch.Get "superuser_username" }}
|
||||
{{ else if $page.Params.authors }}
|
||||
{{ $author_username = index $page.Params.authors 0 }}
|
||||
{{ end }}
|
||||
{{ $author := "" }}
|
||||
{{ $taxonomy := "authors" }}
|
||||
{{ $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $author_username) }}
|
||||
{{ with $profile_page }}
|
||||
{{ $author = .Params.name | default .Title }}
|
||||
{{ end }}
|
||||
|
||||
<script type="application/ld+json">
|
||||
{
|
||||
"@context": "https://schema.org",
|
||||
"@type": "Event",
|
||||
"mainEntityOfPage": {
|
||||
"@type": "WebPage",
|
||||
"@id": {{$page.Permalink}}
|
||||
},
|
||||
"name": {{$page.Title}},
|
||||
{{ with $page.Params.location }}
|
||||
"location": {
|
||||
"@type": "Place",
|
||||
"name": {{. | plainify}}
|
||||
},
|
||||
{{end}}
|
||||
{{ if $featured_image }}
|
||||
"image": [
|
||||
{{$featured_image.Permalink}}
|
||||
],
|
||||
{{end}}
|
||||
"startDate": {{ $page.Date.Format "2006-01-02T15:04:05Z07:00" }},
|
||||
{{with $page.Params.date_end}}
|
||||
"endDate": {{ (time .).Format "2006-01-02T15:04:05Z07:00" }},
|
||||
{{end}}
|
||||
{{with $author}}
|
||||
"performer": {
|
||||
"@type": "Person",
|
||||
"name": {{.}}
|
||||
},
|
||||
{{end}}
|
||||
"description": {{$summary}}
|
||||
}
|
||||
</script>
|
||||
@@ -11,4 +11,8 @@
|
||||
{{ partial "jsonld/article.html" (dict "page" $page "summary" $summary) }}
|
||||
{{ end }}
|
||||
|
||||
{{ if eq $page.Type "talk" }}
|
||||
{{ partial "jsonld/event.html" (dict "page" $page "summary" $summary) }}
|
||||
{{ end }}
|
||||
|
||||
{{- end }}
|
||||
@@ -1,6 +1,6 @@
|
||||
{{- define "main" -}}
|
||||
|
||||
<div class="pub" itemscope itemtype="http://schema.org/Event">
|
||||
<div class="pub">
|
||||
|
||||
{{ partial "page_header.html" . }}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
{{ if .Params.abstract }}
|
||||
<h3>{{ i18n "abstract" }}</h3>
|
||||
<p class="pub-abstract" itemprop="text">{{ .Params.abstract | markdownify | emojify }}</p>
|
||||
<p class="pub-abstract">{{ .Params.abstract | markdownify | emojify }}</p>
|
||||
{{ else }}
|
||||
<br>
|
||||
{{ end }}
|
||||
@@ -18,7 +18,7 @@
|
||||
<div class="col-md-10">
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-3 pub-row-heading">{{ i18n "date" }}</div>
|
||||
<div class="col-12 col-md-9" itemprop="datePublished">
|
||||
<div class="col-12 col-md-9">
|
||||
{{ partial "functions/get_event_dates" . }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user