Skip to content

Commit

Permalink
Merge pull request #1080 from gethinode/develop
Browse files Browse the repository at this point in the history
Improve handling of unspecified post date
  • Loading branch information
markdumay authored Aug 11, 2024
2 parents 0513692 + 8312de3 commit cc22f73
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 49 deletions.
22 changes: 0 additions & 22 deletions hugo_stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
"a",
"body",
"button",
"code",
"div",
"footer",
"form",
"h2",
"head",
"html",
"i",
"img",
"input",
"label",
Expand All @@ -22,7 +19,6 @@
"ol",
"p",
"path",
"pre",
"script",
"small",
"span",
Expand All @@ -36,14 +32,10 @@
"align-items-center",
"align-self-center",
"align-self-end",
"anchor",
"ball",
"bg-body",
"bg-opacity-10",
"bg-primary",
"border-bottom",
"border-end",
"border-start",
"bottom-0",
"bottom-bar",
"breadcrumb",
Expand All @@ -52,7 +44,6 @@
"btn-close",
"btn-primary",
"checkbox",
"chroma",
"col",
"col-12",
"col-6",
Expand Down Expand Up @@ -82,7 +73,6 @@
"fa-face-frown",
"fa-fw",
"fa-github",
"fa-link",
"fa-linkedin",
"fa-medium",
"fa-moon",
Expand All @@ -92,15 +82,12 @@
"fixed-top",
"flex-column",
"flex-fill",
"font-monospace",
"footer",
"form-control",
"fs-3",
"fs-5",
"fw-30",
"fw-bold",
"heading",
"highlight",
"hstack",
"img-fluid",
"img-wrap",
Expand All @@ -114,7 +101,6 @@
"link-secondary",
"main-content",
"main-nav-toggler",
"mb-3",
"me-auto",
"middle-bar",
"min-vh-100",
Expand All @@ -123,15 +109,12 @@
"ms-md-3",
"mt-3",
"mt-5",
"multi-file-collapse-1",
"mx-auto",
"mx-md-0",
"my-auto",
"my-md-auto",
"nav",
"nav-item",
"nav-link",
"nav-tabs",
"navbar",
"navbar-brand",
"navbar-collapse",
Expand Down Expand Up @@ -171,9 +154,7 @@
"search-input",
"search-suggestions",
"shadow",
"show",
"svg-inline--fa",
"syntax-highlight",
"text-center",
"text-decoration-none",
"text-muted",
Expand All @@ -188,9 +169,6 @@
"top-bar"
],
"ids": [
"body-file-collapse-1",
"file",
"footer-file-collapse-1",
"navbar-0-collapse",
"navbar-mode",
"navbar-mode-checkbox",
Expand Down
14 changes: 8 additions & 6 deletions layouts/_default/single/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@

{{ with .Title }}<p class="display-4 mt-5">{{ . }}</p>{{ end }}
{{ if ne $metadata "none" }}
{{ $lastmodstr := (partial "utilities/date.html" (dict "date" .Lastmod "format" "long")) -}}
{{ $datestr := (partial "utilities/date.html" (dict "date" .Date "format" "long")) -}}
<small class="text-body-secondary text-uppercase">
{{ $datestr | i18n "postedOnDate" -}}
{{ if eq $metadata "full" }}
{{ if ne $datestr $lastmodstr -}}&nbsp;({{ $lastmodstr | i18n "lastModified" }}){{ end }}
{{ if .Date }}
{{ $lastmodstr := (partial "utilities/date.html" (dict "date" .Lastmod "format" "long")) -}}
{{ $datestr := (partial "utilities/date.html" (dict "date" .Date "format" "long")) -}}
{{ $datestr | i18n "postedOnDate" -}}
{{ if eq $metadata "full" }}
{{ if ne $datestr $lastmodstr -}}&nbsp;({{ $lastmodstr | i18n "lastModified" }}){{ end }}
{{ end }}
&bull;
{{ end }}
&bull;
{{ .ReadingTime | lang.FormatNumber 0 }}&nbsp;{{ i18n "minutesShort" }} {{ i18n "read" }} &bull;
{{ .WordCount | lang.FormatNumber 0 }}&nbsp;{{ i18n "words" }}
</small>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/assets/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

<p class="card-text"><small class="{{ if $color }}text-bg-{{ $color }}{{ else }}text-body-secondary{{ end }} text-uppercase">
{{- if in (slice "full" "publication") $keywords -}}
{{- partial "utilities/date.html" (dict "date" $page.Date "format" "long") -}}&nbsp;&bull;
{{ with $page.Date }}{{- partial "utilities/date.html" (dict "date" . "format" "long") -}}&nbsp;&bull;{{ end }}
{{ $page.ReadingTime | lang.FormatNumber 0 }} {{ i18n "minutesShort" }} {{ i18n "read" -}}
{{- end -}}

Expand Down
22 changes: 7 additions & 15 deletions layouts/partials/head/structured-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
{{ end -}}
{{ end -}}

{{ $alt := slice .Site.Params.schema.twitter .Site.Params.schema.linkedin .Site.Params.schema.github }}

<script type="application/ld+json">
{
"@context": "https://schema.org",
Expand All @@ -31,17 +33,7 @@
{{ end -}}
"name": "{{ .Site.Params.schema.name }}",
"url": {{ print $baseURL }},
"sameAs": [
{{ with .Site.Params.schema.twitter -}}
{{ . }}
{{ end -}}
{{ with .Site.Params.schema.linkedin -}}
, {{ . }}
{{ end -}}
{{ with .Site.Params.schema.github -}}
, {{ . }}
{{ end -}}
],
"sameAs": {{ $alt | uniq | complement (slice "") }},
{{ if eq .Site.Params.schemaType "Organization" -}}
"logo": {
"@type": "ImageObject",
Expand Down Expand Up @@ -103,8 +95,8 @@
"@id": {{ print $baseURL "#/schema/person/1" }}
},
{{ end -}}
"datePublished": "{{ .Date.Format "2006-01-02T15:04:05CET" }}",
"dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}",
{{ with .Date }}"datePublished": "{{ .Format "2006-01-02T15:04:05CET" }}",{{ end -}}
{{ with .Lastmod }}"dateModified": "{{ .Format "2006-01-02T15:04:05CET" }}",{{ end -}}
"breadcrumb": {
"@id": {{ print .Permalink "#/schema/breadcrumb/1" }}
},
Expand Down Expand Up @@ -151,8 +143,8 @@
"mainEntityOfPage": {
"@id": {{ .Permalink }}
},
"datePublished": "{{ .Date.Format "2006-01-02T15:04:05CET" }}",
"dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05CET" }}",
{{ with .Date }}"datePublished": "{{ .Format "2006-01-02T15:04:05CET" }}",{{ end -}}
{{ with .Lastmod }}"dateModified": "{{ .Format "2006-01-02T15:04:05CET" }}",{{ end -}}
"author": {
"@id": {{ print $baseURL "#/schema/person/2" }}
},
Expand Down
2 changes: 0 additions & 2 deletions layouts/partials/utilities/git.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{{ $lastmodstr := (partial "utilities/date.html" (dict "date" .Lastmod "format" "long")) -}}
{{ $lastmodstr | i18n "lastModified" -}}
{{ with .GitInfo }}
&bull;&nbsp;<a href="{{ site.Params.docs.github | default site.Params.schema.github }}/commit/{{ .Hash }}">{{ .Subject }} ({{ .AbbreviatedHash }})</a>
{{ end -}}
10 changes: 7 additions & 3 deletions layouts/tags/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@
{{ $lastYear := $.Scratch.Get "lastYear"}}
<div class="row mt-2">
<div class="d-none d-{{ $breakpoint.prev }}-block col-{{ $breakpoint.prev }}-3 mt-auto text-right">
<time class="post-date" datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
{{ (partial "utilities/date.html" (dict "date" .Date "format" "medium")) }}
</time>
{{ with .Date }}
<time class="post-date" datetime="{{ .Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
{{ (partial "utilities/date.html" (dict "date" . "format" "medium")) }}
</time>
{{ else }}
-
{{ end }}
</div>
<div class="col">
{{ if ne $year $lastYear }}
Expand Down

0 comments on commit cc22f73

Please sign in to comment.