Skip to content

Commit 15d3e40

Browse files
authored
feat: add parameter geekdocPageLastmod (thegeeklab#895)
1 parent bb6cf71 commit 15d3e40

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

exampleSite/config/_default/params.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ geekdocTagsToMenu: true
1111

1212
geekdocRepo: https://github.com/thegeeklab/hugo-geekdoc
1313
geekdocEditPath: edit/main/exampleSite
14+
geekdocPageLastmod: false
1415

1516
geekdocSearch: true
1617
geekdocSearchShowParent: true

exampleSite/content/en/usage/configuration.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ enableRobotsTXT = true
7070
# You can also specify this parameter per page in front matter.
7171
geekdocEditPath = "edit/main/exampleSite"
7272

73+
# (Optional, default false) Show last modification date of the page in the header.
74+
# Keep in mind that last modification date works best if `enableGitInfo` is set to true.
75+
geekdocPageLastmod = true
76+
7377
# (Optional, default true) Enables search function with flexsearch.
7478
# Index is built on the fly and might slow down your website.
7579
geekdocSearch = false
@@ -196,6 +200,10 @@ params:
196200
# You can also specify this parameter per page in front matter.
197201
geekdocEditPath: edit/main/exampleSite
198202

203+
# (Optional, default false) Show last modification date of the page in the header.
204+
# Keep in mind that last modification date works best if `enableGitInfo` is set to true.
205+
geekdocPageLastmod: true
206+
199207
# (Optional, default true) Enables search function with flexsearch.
200208
# Index is built on the fly and might slow down your website.
201209
geekdocSearch: false
@@ -294,6 +302,9 @@ geekdocRepo = "https://github.com/thegeeklab/hugo-geekdoc"
294302
# the parent directory of the 'content' folder.
295303
geekdocEditPath = "edit/main/exampleSite"
296304

305+
# Show last modification date of the page in the header.
306+
geekdocPageLastmod = true
307+
297308
# Used for 'Edit page' link, set to '.File.Path' by default.
298309
# Can be overwritten by a path relative to 'geekdocEditPath'
299310
geekdocFilePath =
@@ -354,6 +365,9 @@ geekdocRepo: "https://github.com/thegeeklab/hugo-geekdoc"
354365
# the parent directory of the 'content' folder.
355366
geekdocEditPath: "edit/main/exampleSite"
356367

368+
# Show last modification date of the page in the header.
369+
geekdocPageLastmod: true
370+
357371
# Used for 'Edit page' link, set to '.File.Path' by default.
358372
# Can be overwritten by a path relative to 'geekdocEditPath'
359373
geekdocFilePath:

layouts/_default/single.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class="gdoc-markdown gdoc-markdown__align--{{ default "left" (.Page.Params.geekdocAlign | lower) }}"
77
>
88
<h1>{{ partial "utils/title" . }}</h1>
9+
{{ partial "page-metadata" . }}
910
{{ partial "utils/content" . }}
1011
</article>
1112
{{ end }}

layouts/partials/page-metadata.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{{- $showPageLastmod := (or (default false .Page.Params.geekdocPageLastmod) (default false .Site.Params.geekdocPageLastmod)) -}}
2+
3+
{{- if $showPageLastmod -}}
4+
<span class="flex align-center no-wrap">
5+
<svg class="gdoc-icon gdoc_date"><use xlink:href="#gdoc_date"></use></svg>
6+
<time datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
7+
{{ if .Lastmod.After (.Date.AddDate 0 0 1) }}
8+
{{ i18n "posts_update_prefix" }}
9+
{{ end }}
10+
{{ .Lastmod.Format "Jan 2, 2006" }}
11+
</time>
12+
</span>
13+
{{- end -}}

0 commit comments

Comments
 (0)