Rename DateFormat to BookDateFormat, make format optional

This commit is contained in:
Alex Shpak 2019-03-29 16:59:00 +01:00
parent 5b652a1bb1
commit 941ca77a32
5 changed files with 19 additions and 12 deletions

View file

@ -101,9 +101,6 @@ enableGitInfo: true
disableKinds: ["taxonomy", "taxonomyTerm"] disableKinds: ["taxonomy", "taxonomyTerm"]
params: params:
# Configure the date format utilised on the pages - TODO, review git-footer.html
DateFormat: "January 2, 2006"
# (Optional, default true) Show or hide table of contents globally # (Optional, default true) Show or hide table of contents globally
# You can also specify this parameter per page in front matter # You can also specify this parameter per page in front matter
BookShowToC: true BookShowToC: true
@ -116,10 +113,10 @@ params:
# You can also set value to "*" to render all sections to menu # You can also set value to "*" to render all sections to menu
BookSection: docs BookSection: docs
# This value is duplicate of $link-color for making active link highlight in menu bundle mode # (Optional) This value is duplicate of $link-color for making active link highlight in menu bundle mode
# BookMenuBundleActiveLinkColor: \#004ed0 # BookMenuBundleActiveLinkColor: \#004ed0
# Include JS scripts in pages. Disabled by default. # (Optional, default false) Include JS scripts in pages. Disabled by default.
# - Keep side menu on same scroll position during navigation # - Keep side menu on same scroll position during navigation
BookEnableJS: true BookEnableJS: true
@ -131,6 +128,11 @@ params:
# Disabled by default. Uncomment to enable. Requires 'BookRepo' param. # Disabled by default. Uncomment to enable. Requires 'BookRepo' param.
# Path must point to 'content' directory of repo. # Path must point to 'content' directory of repo.
BookEditPath: edit/master/exampleSite/content BookEditPath: edit/master/exampleSite/content
# (Optional, default January 2, 2006) Configure the date format used on the pages
# - In git information
# - In blog posts
BookDateFormat: "Jan 2, 2006"
``` ```

View file

@ -15,9 +15,6 @@ pygmentsStyle: monokailight
pygmentsCodeFences: true pygmentsCodeFences: true
params: params:
# Configure the date format utilised on the pages
DateFormat: "Jan 2, 2006"
# (Optional, default true) Show or hide table of contents globally # (Optional, default true) Show or hide table of contents globally
# You can also specify this parameter per page in front matter # You can also specify this parameter per page in front matter
BookShowToC: true BookShowToC: true
@ -45,3 +42,8 @@ params:
# Disabled by default. Uncomment to enable. Requires 'BookRepo' param. # Disabled by default. Uncomment to enable. Requires 'BookRepo' param.
# Path must point to 'content' directory of repo. # Path must point to 'content' directory of repo.
BookEditPath: edit/master/exampleSite/content BookEditPath: edit/master/exampleSite/content
# Configure the date format used on the pages
# - In git information
# - In blog posts
BookDateFormat: "Jan 2, 2006"

View file

@ -2,8 +2,9 @@
<div class="align-center book-git-footer {{ if not .GitInfo }}justify-end{{ else }}justify-between{{ end }}"> <div class="align-center book-git-footer {{ if not .GitInfo }}justify-end{{ else }}justify-between{{ end }}">
{{ with .GitInfo }} {{ with .GitInfo }}
<div> <div>
<a href="{{ $.Site.Params.BookRepo }}/commit/{{ .Hash }}" title='Last modified {{ .AuthorDate.Local.Format $.Site.Params.DateFormat }} by {{ .AuthorName }}' target="_blank" rel="noopener"> {{- $date := .AuthorDate.Local.Format (default "January 2, 2006" $.Site.Params.BookDateFormat) -}}
<img src="{{ "svg/code-merge.svg" | relURL }}" /> {{ .AuthorDate.Local.Format $.Site.Params.DateFormat }} <a href="{{ $.Site.Params.BookRepo }}/commit/{{ .Hash }}" title='Last modified {{ $date }} by {{ .AuthorName }}' target="_blank" rel="noopener">
<img src="{{ "svg/code-merge.svg" | relURL }}" /> {{ $date }}
</a> </a>
</div> </div>
{{ end }} {{ end }}

View file

@ -1,4 +1,5 @@
{{ define "main" }} {{ define "main" }}
{{- $dateFormat := default "January 2, 2006" .Site.Params.BookDateFormat -}}
{{ $paginator := .Paginate (where .Pages "Params.hidden" "ne" true) }} {{ $paginator := .Paginate (where .Pages "Params.hidden" "ne" true) }}
{{ range sort .Paginator.Pages }} {{ range sort .Paginator.Pages }}
<article> <article>
@ -6,7 +7,7 @@
<a href="{{ .RelPermalink }}">{{ .Title }}</a> <a href="{{ .RelPermalink }}">{{ .Title }}</a>
</h2> </h2>
<h5> <h5>
<strong>{{ .Date.Format .Site.Params.DateFormat }}</strong> <strong>{{ .Date.Format $dateFormat }}</strong>
</h5> </h5>
<p class="markdown"> <p class="markdown">
{{- .Summary -}} {{- .Summary -}}

View file

@ -1,8 +1,9 @@
{{ define "main" }} {{ define "main" }}
{{- $dateFormat := default "January 2, 2006" .Site.Params.BookDateFormat -}}
<header> <header>
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
<h5> <h5>
<strong>{{ .Date.Format .Site.Params.DateFormat }}</strong> <strong>{{ .Date.Format $dateFormat }}</strong>
</h5> </h5>
</header> </header>
<article class="markdown"> <article class="markdown">