refactor: strip out Microdata for list items and page metadata

Forms part of the transition from Microdata to JSON-LD.

See #413
This commit is contained in:
George Cushen committed 2019-09-09 13:59:22 +01:00
1 parent 76ade21d36
commit 5d590b64f6
7 files changed
+43 -61

No files matched your search

+10 -15
View File
@@ -1,16 +1,11 @@
{{ $item := . }}
{{ $microdata_type := "CreativeWork" }}
{{ $show_buttons := false }}
{{/* Dynamic view adjusts to content type. */}}
{{ if eq $item.Type "post" }}
{{ $microdata_type = "BlogPosting" }}
{{ else if eq $item.Type "talk" }}
{{ $microdata_type = "Event" }}
{{ $show_buttons := false }}
{{ if eq $item.Type "talk" }}
{{ $show_buttons = true }}
{{ else if eq $item.Type "publication" }}
{{ $microdata_type = "ScholarlyArticle" }}
{{ $show_buttons = true }}
{{ end }}
@@ -26,21 +21,21 @@
{{ $summary = $item.Content }}
{{ end }}
<div class="card-simple" itemscope itemtype="http://schema.org/{{$microdata_type}}">
<div class="card-simple">
{{ if eq $item.Type "talk" }}
<div class="article-metadata">
{{ if $item.Params.authors }}
<div itemprop="author">
<div>
{{ partial "page_metadata_authors" $item }}
</div>
{{ end }}
<span itemprop="startDate">
<span>
{{ partial "functions/get_event_dates" $item }}
</span>
{{ with $item.Params.location }}
<span class="middot-divider"></span>
<span itemprop="location">{{ . }}</span>
<span>{{ . }}</span>
{{ end }}
</div>
{{ else }}
@@ -52,16 +47,16 @@
{{ with $resource }}
{{ $image := .Fill (printf "918x517 q90 %s" $anchor) }}
<a href="{{ $item.RelPermalink }}">
<img src="{{ $image.RelPermalink }}" class="article-banner" itemprop="image" alt="">
<img src="{{ $image.RelPermalink }}" class="article-banner" alt="">
</a>
{{end}}
<h3 class="article-title mb-1 mt-3" itemprop="name">
<a href="{{ $item.RelPermalink }}" itemprop="url">{{ $item.Title }}</a>
<h3 class="article-title mb-1 mt-3">
<a href="{{ $item.RelPermalink }}">{{ $item.Title }}</a>
</h3>
{{ with $summary }}
<div class="article-style" itemprop="articleBody">
<div class="article-style">
<p>{{.}}</p>
</div>
{{ end }}
+5 -5
View File
@@ -1,14 +1,14 @@
<div class="pub-list-item" style="margin-bottom: 1rem" itemscope itemtype="http://schema.org/CreativeWork">
<div class="pub-list-item" style="margin-bottom: 1rem">
<i class="far fa-file-alt pub-icon" aria-hidden="true"></i>
{{/* APA Style */}}
{{ if eq (site.Params.publications.citation_style | default "apa") "apa" }}
<span itemprop="author" class="article-metadata li-cite-author">
<span class="article-metadata li-cite-author">
{{ partial "page_metadata_authors" . }}
</span>
({{- .Date.Format "2006" -}}).
<a href="{{ .RelPermalink }}" itemprop="name">{{ .Title }}</a>.
<a href="{{ .RelPermalink }}">{{ .Title }}</a>.
{{ if .Params.publication_short }}
{{- .Params.publication_short | markdownify -}}.
{{ else if .Params.publication }}
@@ -19,10 +19,10 @@
{{/* MLA Style */}}
{{ else }}
<span itemprop="author" class="article-metadata li-cite-author">
<span class="article-metadata li-cite-author">
{{ partial "page_metadata_authors" . }}
</span>.
<a href="{{ .RelPermalink }}" itemprop="name">{{ .Title }}</a>.
<a href="{{ .RelPermalink }}">{{ .Title }}</a>.
{{ if .Params.publication_short }}
{{- .Params.publication_short | markdownify -}},
{{ else if .Params.publication }}
+10 -17
View File
@@ -1,6 +1,6 @@
{{ $item := . }}
{{ $microdata_type := "CreativeWork" }}
{{/* Dynamic view adjusts to content type. */}}
{{ $show_authors_only := false }}{{/* Show authors only or full metadata? */}}
{{ $show_buttons := false }}
{{ $link := $item.RelPermalink }}
@@ -9,20 +9,13 @@
{{ $link = $item.Params.external_link }}
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
{{ end }}
{{/* Dynamic view adjusts to content type. */}}
{{ if eq $item.Type "post" }}
{{ $microdata_type = "BlogPosting" }}
{{ else if eq $item.Type "talk" }}
{{ $microdata_type = "Event" }}
{{ if eq $item.Type "talk" }}
{{ $show_authors_only = true }}
{{ $show_buttons = true }}
{{ else if eq $item.Type "publication" }}
{{ $microdata_type = "ScholarlyArticle" }}
{{ $show_authors_only = true }}
{{ $show_buttons = true }}
{{ else if eq $item.Type "project" }}
{{ $microdata_type = "CreativeWork" }}
{{ $show_authors_only = true }}
{{ $show_buttons = true }}
{{ end }}
@@ -37,15 +30,15 @@
{{ $summary = $item.Summary }}
{{ end }}
<div class="media stream-item" itemscope itemtype="http://schema.org/{{$microdata_type}}">
<div class="media stream-item">
<div class="media-body">
<h3 class="article-title mb-0 mt-0" itemprop="name">
<a href="{{$link}}" {{ $target | safeHTMLAttr }} itemprop="url">{{ $item.Title }}</a>
<h3 class="article-title mb-0 mt-0">
<a href="{{$link}}" {{ $target | safeHTMLAttr }}>{{ $item.Title }}</a>
</h3>
{{ with $summary }}
<div class="article-style" itemprop="articleBody">
<div class="article-style">
{{ . | truncate 135 }}
</div>
{{ end }}
@@ -54,18 +47,18 @@
{{ if eq $item.Type "talk" }}
<div>
<span itemprop="startDate">
<span>
{{ partial "functions/get_event_dates" $item }}
</span>
{{ with $item.Params.location }}
<span class="middot-divider"></span>
<span itemprop="location">{{ . }}</span>
<span>{{ . }}</span>
{{ end }}
</div>
{{ end }}
{{ if and $show_authors_only $item.Params.authors }}
<div itemprop="author">
<div>
{{ partial "page_metadata_authors" $item }}
</div>
{{ else if not $show_authors_only }}
@@ -85,7 +78,7 @@
{{ with $resource }}
{{ $image := .Resize "150x" }}
<a href="{{$link}}" {{ $target | safeHTMLAttr }}>
<img src="{{ $image.RelPermalink }}" itemprop="image">
<img src="{{ $image.RelPermalink }}" alt="">
</a>
{{end}}
</div>
+6 -12
View File
@@ -1,6 +1,6 @@
{{ $item := . }}
{{ $microdata_type := "CreativeWork" }}
{{/* Dynamic view adjusts to content type. */}}
{{ $icon_pack := "far" }}
{{ $icon := "fa-file-alt" }}
{{ $show_authors := false }}
@@ -11,44 +11,38 @@
{{ $link = $item.Params.external_link }}
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
{{ end }}
{{/* Dynamic view adjusts to content type. */}}
{{ if eq $item.Type "post" }}
{{ $microdata_type = "BlogPosting" }}
{{ $icon = "fa-newspaper" }}
{{ else if eq $item.Type "talk" }}
{{ $microdata_type = "Event" }}
{{ $icon = "fa-calendar-alt" }}
{{ else if eq $item.Type "publication" }}
{{ $microdata_type = "ScholarlyArticle" }}
{{ $show_authors = true }}
{{ $show_buttons = true }}
{{ else if eq $item.Type "project" }}
{{ $microdata_type = "CreativeWork" }}
{{ $icon_pack = "fas" }}
{{ $icon = "fa-project-diagram" }}
{{ $show_authors = true }}
{{ $show_buttons = true }}
{{ end }}
<div class="view-list-item" itemscope itemtype="http://schema.org/{{$microdata_type}}">
<div class="view-list-item">
<i class="{{$icon_pack}} {{$icon}} pub-icon" aria-hidden="true"></i>
<a href="{{$link}}" {{ $target | safeHTMLAttr }} itemprop="url"><span itemprop="name">{{ $item.Title }}</span></a>
<a href="{{$link}}" {{ $target | safeHTMLAttr }}>{{ $item.Title }}</a>
{{ if eq $item.Type "talk" }}
<div class="article-metadata">
<span itemprop="startDate">
<span>
{{ partial "functions/get_event_dates" $item }}
</span>
{{ with $item.Params.location }}
<span class="middot-divider"></span>
<span itemprop="location">{{ . }}</span>
<span>{{ . }}</span>
{{ end }}
</div>
{{ end }}
{{ if and $show_authors $item.Params.authors }}
<div class="article-metadata" itemprop="author">
<div class="article-metadata">
{{ partial "page_metadata_authors" $item }}
</div>
{{ end }}
+6 -6
View File
@@ -25,18 +25,18 @@
{{ $profile_url = site.BaseURL }}
{{ end }}
{{ $avatar := (.Resources.ByType "image").GetMatch "*avatar*" }}
<div class="media author-card" itemscope itemtype="http://schema.org/Person">
<div class="media author-card">
{{ if and site.Params.gravatar .Params.email }}
<img class="portrait mr-3" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" itemprop="image" alt="Avatar">
<img class="portrait mr-3" src="https://s.gravatar.com/avatar/{{ md5 .Params.email }}?s=200')" alt="Avatar">
{{ else if $avatar }}
{{ $avatar_image := $avatar.Fill "250x250 Center" }}
<img class="portrait mr-3" src="{{ $avatar_image.RelPermalink }}" itemprop="image" alt="Avatar">
<img class="portrait mr-3" src="{{ $avatar_image.RelPermalink }}" alt="Avatar">
{{ end }}
<div class="media-body">
<h5 class="card-title" itemprop="name"><a href="{{$profile_url}}">{{.Params.name}}</a></h5>
<h5 class="card-title"><a href="{{$profile_url}}">{{.Params.name}}</a></h5>
{{ with .Params.role }}<h6 class="card-subtitle">{{. | markdownify | emojify}}</h6>{{end}}
{{ with .Params.bio }}<p class="card-text" itemprop="description">{{. | markdownify | emojify}}</p>{{end}}
{{ with .Params.bio }}<p class="card-text">{{. | markdownify | emojify}}</p>{{end}}
<ul class="network-icon" aria-hidden="true">
{{ range .Params.social }}
{{ $pack := or .icon_pack "fas" }}
@@ -53,7 +53,7 @@
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
{{ end }}
<li>
<a itemprop="sameAs" href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}>
<a href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}>
<i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }}"></i>
</a>
</li>
+1 -1
View File
@@ -6,7 +6,7 @@
{{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy (. | urlize)) -}}
{{- $name := $profile_page.Params.name | default ($value|markdownify) -}}
{{- if gt $index 0 }}, {{ end -}}
<span itemprop="author name" itemtype="http://schema.org/Person">
<span>
{{- with $profile_page -}}
<a href="{{.RelPermalink}}">{{$name}}</a>
{{- else -}}
+5 -5
View File
@@ -30,17 +30,17 @@
{{ $js_tag_classes := delimit (apply (apply $item.Params.tags "replace" "." " " "-") "printf" "js-id-%s" ".") " " }}
<div class="col-lg-12 project-item isotope-item {{ $js_tag_classes | safeHTMLAttr }}" itemscope itemtype="http://schema.org/CreativeWork">
<div class="col-lg-12 project-item isotope-item {{ $js_tag_classes | safeHTMLAttr }}">
<div class="row align-items-center">
<div class="col-12 col-md-6">
<h3 class="article-title mb-0 mt-0" itemprop="name">
{{- if $do_link}}<a href="{{ $link }}" {{ $target | safeHTMLAttr }} itemprop="url">{{end -}}
<h3 class="article-title mb-0 mt-0">
{{- if $do_link}}<a href="{{ $link }}" {{ $target | safeHTMLAttr }}>{{end -}}
{{ $item.Title | markdownify | emojify }}
{{- if $do_link}}</a>{{end -}}
</h3>
{{ with $summary }}
<div class="article-style" itemprop="articleBody">
<div class="article-style">
{{ . }}
</div>
{{ end }}
@@ -55,7 +55,7 @@
{{ with $resource }}
{{ $image := .Resize "540x" }}
{{if $do_link}}<a href="{{ $link }}" {{ $target | safeHTMLAttr }}>{{end}}
<img src="{{ $image.RelPermalink }}" itemprop="image" alt="">
<img src="{{ $image.RelPermalink }}" alt="">
{{if $do_link}}</a>{{end}}
{{end}}
</div>