From 40a8705ab6ba5cbf3bb6e4de0a15c6ef50b00c7e Mon Sep 17 00:00:00 2001 From: Henk Verlinde Date: Mon, 17 Jan 2022 19:50:23 +0100 Subject: [PATCH] feat: add last modified date as an option --- assets/scss/layouts/_pages.scss | 24 ++++++++++++++++++++---- config/_default/params.toml | 1 + layouts/docs/single.html | 11 ++++++++--- layouts/partials/main/date.html | 6 ++++++ layouts/partials/main/edit-page.html | 11 +++-------- layouts/partials/main/last-modified.html | 10 ++++++++++ 6 files changed, 48 insertions(+), 15 deletions(-) create mode 100644 layouts/partials/main/date.html create mode 100644 layouts/partials/main/last-modified.html diff --git a/assets/scss/layouts/_pages.scss b/assets/scss/layouts/_pages.scss index 2f6ac56..405ede9 100644 --- a/assets/scss/layouts/_pages.scss +++ b/assets/scss/layouts/_pages.scss @@ -23,13 +23,29 @@ h4:hover a { margin-top: 2.25rem; } -.edit-page { +.page-footer-meta { margin-top: 3rem; - font-size: $font-size-base; } -.edit-page svg { - margin-right: 0.5rem; +.edit-page, +.last-modified { + font-size: $font-size-sm; + margin-top: 0.25rem; + margin-bottom: 0.25rem; +} + +@include media-breakpoint-up(md) { + .edit-page, + .last-modified { + font-size: $font-size-base; + margin-top: 0.75rem; + margin-bottom: 0.25rem; + } +} + +.edit-page svg, +.last-modified svg { + margin-right: 0.25rem; margin-bottom: 0.25rem; } diff --git a/config/_default/params.toml b/config/_default/params.toml index f08e676..b9f36ca 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -72,6 +72,7 @@ repoHost = "GitHub" docsRepo = "https://github.com/h-enk/doks" docsRepoBranch = "master" editPage = false +lastMod = false [options] lazySizes = true diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 28bb90b..55fd0e1 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -32,9 +32,14 @@ {{ end -}} {{ .Content }} - {{ if .Site.Params.editPage -}} - {{ partial "main/edit-page.html" . }} - {{ end -}} + {{ partial "main/docs-navigation.html" . }} +{{ $format := default "January 2, 2006" .Format -}} +{{ return (.Date.Format $format) -}} \ No newline at end of file diff --git a/layouts/partials/main/edit-page.html b/layouts/partials/main/edit-page.html index e8c901a..30c0dba 100644 --- a/layouts/partials/main/edit-page.html +++ b/layouts/partials/main/edit-page.html @@ -10,18 +10,13 @@ {{ end }} {{ $contentPath := print .Site.Params.docsRepo $editPath .Site.Params.docsRepoBranch "/content/" }} +{{ $url := print $contentPath .Lang "/" $filePath }} -{{ $url := print $contentPath $filePath }} - -{{ if .Site.Params.options.multilingualMode }} - {{ $url = print $contentPath .Lang "/" $filePath }} -{{ end }} - -

+

Edit this page on {{ .Site.Params.repoHost }} -

+
diff --git a/layouts/partials/main/last-modified.html b/layouts/partials/main/last-modified.html new file mode 100644 index 0000000..edb6c7d --- /dev/null +++ b/layouts/partials/main/last-modified.html @@ -0,0 +1,10 @@ +{{ if and .GitInfo .Site.Params.docsRepo -}} + {{- $date := partial "main/date" (dict "Date" .GitInfo.AuthorDate.Local "Format" .Site.Params.BookDateFormat) -}} + {{- $commitPath := default "commit" .Site.Params.BookCommitPath -}} +
+ + + Last modified on {{ $date }} + +
+{{ end -}} \ No newline at end of file