From cf83cf19258477c7617defe98480820425a70256 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Sat, 18 Mar 2023 18:46:32 -0400 Subject: [PATCH] added git revision info to bottom of pages (if available) ; add 'back to top' link to footer ; add shortcodes for change log ; add shortcode for back to top to be used with headings --- config.toml | 1 + themes/hugo-xmin/exampleSite/config.toml | 1 + themes/hugo-xmin/layouts/_default/single.html | 2 +- themes/hugo-xmin/layouts/partials/footer.html | 21 +++++-------------- .../layouts/shortcodes/back_to_top.html | 1 + .../hugo-xmin/layouts/shortcodes/change.html | 2 ++ .../layouts/shortcodes/changelog.html | 3 +++ themes/hugo-xmin/static/css/style.css | 2 ++ 8 files changed, 16 insertions(+), 17 deletions(-) create mode 100644 themes/hugo-xmin/layouts/shortcodes/back_to_top.html create mode 100644 themes/hugo-xmin/layouts/shortcodes/change.html create mode 100644 themes/hugo-xmin/layouts/shortcodes/changelog.html diff --git a/config.toml b/config.toml index 3a7674c..fa0cebf 100644 --- a/config.toml +++ b/config.toml @@ -7,6 +7,7 @@ timeZone = 'UTC' enableEmoji = true enableRobotsTXT = true +enableGitInfo = true rssLimit = 25 ignoreFiles = [ '.gitignore', '.gitkeep' ] diff --git a/themes/hugo-xmin/exampleSite/config.toml b/themes/hugo-xmin/exampleSite/config.toml index a785bab..512da71 100644 --- a/themes/hugo-xmin/exampleSite/config.toml +++ b/themes/hugo-xmin/exampleSite/config.toml @@ -7,6 +7,7 @@ timeZone = 'UTC' enableEmoji = true enableRobotsTXT = true +enableGitInfo = true rssLimit = 25 ignoreFiles = [ '.gitignore', '.gitkeep' ] diff --git a/themes/hugo-xmin/layouts/_default/single.html b/themes/hugo-xmin/layouts/_default/single.html index 8139eac..e9944ff 100644 --- a/themes/hugo-xmin/layouts/_default/single.html +++ b/themes/hugo-xmin/layouts/_default/single.html @@ -1,7 +1,7 @@ {{ partial "header.html" . }}

{{ .Title | markdownify }}

-{{ with .Params.author }}

{{ . }}

{{ end }} +{{ with .Params.author }}

By: {{ . }}

{{ end }} {{ if (gt .Date 0) }}

Published: {{ .Date.Format "2006/01/02" }}

{{ end }} {{ if (gt .Lastmod 0) }}

Last Modified: {{ .Lastmod.Format "2006/01/02" }}

{{ end }}

diff --git a/themes/hugo-xmin/layouts/partials/footer.html b/themes/hugo-xmin/layouts/partials/footer.html index 0689dd3..2bf71be 100644 --- a/themes/hugo-xmin/layouts/partials/footer.html +++ b/themes/hugo-xmin/layouts/partials/footer.html @@ -2,23 +2,12 @@ {{ partial "foot_custom.html" . }} {{ with .Site.Params.footer }}


- {{ replace . "{Year}" now.Year | markdownify}} + Back to top +
{{ replace . "{Year}" now.Year | markdownify}} {{ end }} - {{ if .File.Path }} - {{ $.Scratch.Set "FilePath" .File.Path }} - {{ $RmdFile := (print .File.BaseFileName ".Rmd") }} - {{ $Files := readDir (print "content/" .File.Dir) }} - {{ if (where $Files "Name" $RmdFile) }} - {{ $.Scratch.Set "FilePath" (print .File.Dir $RmdFile) }} - {{ else }} - {{ $RmdFile := (print .File.BaseFileName ".Rmarkdown") }} - {{ if (where $Files "Name" $RmdFile) }} - {{ $.Scratch.Set "FilePath" (print .File.Dir $RmdFile) }} - {{ end }} - {{ end }} - {{ with .Site.Params.GithubEdit}} - | Edit this page - {{ end }} + {{ if .GitInfo}} +
+ Revision {{ .GitInfo.Hash }} {{ end }} diff --git a/themes/hugo-xmin/layouts/shortcodes/back_to_top.html b/themes/hugo-xmin/layouts/shortcodes/back_to_top.html new file mode 100644 index 0000000..4eb082a --- /dev/null +++ b/themes/hugo-xmin/layouts/shortcodes/back_to_top.html @@ -0,0 +1 @@ +Back to top diff --git a/themes/hugo-xmin/layouts/shortcodes/change.html b/themes/hugo-xmin/layouts/shortcodes/change.html new file mode 100644 index 0000000..d1dfc52 --- /dev/null +++ b/themes/hugo-xmin/layouts/shortcodes/change.html @@ -0,0 +1,2 @@ +
{{ .Get 0 }}
+
{{ .Get 1 }}
diff --git a/themes/hugo-xmin/layouts/shortcodes/changelog.html b/themes/hugo-xmin/layouts/shortcodes/changelog.html new file mode 100644 index 0000000..40f42f2 --- /dev/null +++ b/themes/hugo-xmin/layouts/shortcodes/changelog.html @@ -0,0 +1,3 @@ +
+{{ .Inner | safeHTML }} +
diff --git a/themes/hugo-xmin/static/css/style.css b/themes/hugo-xmin/static/css/style.css index 30a98a4..1d5b114 100644 --- a/themes/hugo-xmin/static/css/style.css +++ b/themes/hugo-xmin/static/css/style.css @@ -17,6 +17,7 @@ body { .terms { font-size: .9em; } .menu, .article-meta, footer { text-align: center; } .title { font-size: 1.1em; } +.back_to_top { font-size: .85em } footer a { text-decoration: none; } hr { border-style: dashed; @@ -59,3 +60,4 @@ table { table thead th { border-bottom: 1px solid #ddd; } th, td { padding: 5px; } thead, tfoot, tr:nth-child(even) { background: #eee; } +