feat: add last modified date as an option

This commit is contained in:
Henk Verlinde 2022-01-17 19:50:23 +01:00
parent 9a9f37b3a2
commit 40a8705ab6
6 changed files with 48 additions and 15 deletions

View File

@ -23,13 +23,29 @@ h4:hover a {
margin-top: 2.25rem; margin-top: 2.25rem;
} }
.edit-page { .page-footer-meta {
margin-top: 3rem; margin-top: 3rem;
font-size: $font-size-base;
} }
.edit-page svg { .edit-page,
margin-right: 0.5rem; .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; margin-bottom: 0.25rem;
} }

View File

@ -72,6 +72,7 @@ repoHost = "GitHub"
docsRepo = "https://github.com/h-enk/doks" docsRepo = "https://github.com/h-enk/doks"
docsRepoBranch = "master" docsRepoBranch = "master"
editPage = false editPage = false
lastMod = false
[options] [options]
lazySizes = true lazySizes = true

View File

@ -32,9 +32,14 @@
</nav> </nav>
{{ end -}} {{ end -}}
{{ .Content }} {{ .Content }}
<div class="page-footer-meta d-flex flex-column flex-md-row justify-content-between">
{{ if .Site.Params.lastMod -}}
{{ partial "main/last-modified.html" . }}
{{ end -}}
{{ if .Site.Params.editPage -}} {{ if .Site.Params.editPage -}}
{{ partial "main/edit-page.html" . }} {{ partial "main/edit-page.html" . }}
{{ end -}} {{ end -}}
</div>
{{ partial "main/docs-navigation.html" . }} {{ partial "main/docs-navigation.html" . }}
<!-- <!--
{{ if not .Site.Params.options.collapsibleSidebar -}} {{ if not .Site.Params.options.collapsibleSidebar -}}

View File

@ -0,0 +1,6 @@
<!--
Returns formatted date.
Usage: partial "docs/date" (dict "Date" .Date "Format" .Site.Params.BookDateFormat)
-->
{{ $format := default "January 2, 2006" .Format -}}
{{ return (.Date.Format $format) -}}

View File

@ -10,18 +10,13 @@
{{ end }} {{ end }}
{{ $contentPath := print .Site.Params.docsRepo $editPath .Site.Params.docsRepoBranch "/content/" }} {{ $contentPath := print .Site.Params.docsRepo $editPath .Site.Params.docsRepoBranch "/content/" }}
{{ $url := print $contentPath .Lang "/" $filePath }}
{{ $url := print $contentPath $filePath }} <div class="edit-page">
{{ if .Site.Params.options.multilingualMode }}
{{ $url = print $contentPath .Lang "/" $filePath }}
{{ end }}
<p class="edit-page">
<a href="{{ $url }}"> <a href="{{ $url }}">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2">
<path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path> <path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path>
</svg> </svg>
Edit this page on {{ .Site.Params.repoHost }} Edit this page on {{ .Site.Params.repoHost }}
</a> </a>
</p> </div>

View File

@ -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 -}}
<div class="last-modified">
<a href="{{ .Site.Params.docsRepo }}/{{ $commitPath }}/{{ .GitInfo.Hash }}">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>
Last modified on {{ $date }}
</a>
</div>
{{ end -}}