Make post meta fields configurable

This commit is contained in:
vimux 2018-11-15 14:21:34 -05:00
parent 982b2eae26
commit 228a06dc5f
No known key found for this signature in database
GPG key ID: 5A34FDC4EE832E34
4 changed files with 20 additions and 12 deletions

View file

@ -85,7 +85,8 @@ googleAnalytics = "" # Enable Google Analytics by entering your tracking id
twitter_cards = true # Enable Twitter Cards if true twitter_cards = true # Enable Twitter Cards if true
cardsPerRow = 2 # Possible values: 1, 2, 3 cardsPerRow = 2 # Possible values: 1, 2, 3
mainSections = ["post"] # Set main page sections mainSections = ["post"] # Set main page sections
dateFormat = "January 02, 2006" # change the format of dates post_meta = ["date", "categories"] # Enable post meta fields in given order
dateFormat = "January 02, 2006" # Change the format of dates
toc = true # Enable Table of Contents for all site pages toc = true # Enable Table of Contents for all site pages
tocOpen = true # Open Table of Contents block. Optional tocOpen = true # Open Table of Contents block. Optional
comments = true # Enable comments for all site pages comments = true # Enable comments for all site pages

View file

@ -1,11 +1,7 @@
{{- if not .Date.IsZero }} {{ $currentPage := . }}
<time class="post__meta-published meta-published" datetime="{{ .Date.Format "2006-01-02T15:04:05" }}">{{ .Date.Format ( .Site.Params.dateFormat | default "January 02, 2006" )}}</time> {{- with .Param "post_meta" }}
{{ end }} {{- range $metaField := . -}}
{{- if ne .Date .Lastmod }} {{- $metaFieldPath := printf "post_meta/%s.html" $metaField -}}
<time class="post__meta-lastmod meta-lastmod" datetime="{{ .Lastmod.Format "2006-01-02T15:04:05" }}">{{ T "meta_lastmod" }}: {{ .Lastmod.Format ( .Site.Params.dateFormat | default "January 02, 2006" )}}</time> {{- partial $metaFieldPath $currentPage -}}
{{- end }} {{ end }}
{{- if .Params.categories }} {{ end }}
<span class="post__meta-categories meta-categories">
<span class="meta-categories__list">{{ T "meta_categories" }}: {{ range $index, $category := .Params.categories }}{{ if gt $index 0 }}, {{ end }}<a class="meta-categories__link" href="{{ "categories/" | relLangURL }}{{ . | urlize | lower }}" rel="category">{{ . }}</a>{{ end }}</span>
</span>
{{- end }}

View file

@ -0,0 +1,5 @@
{{- if .Params.categories }}
<span class="post__meta-categories meta-categories">
<span class="meta-categories__list">{{ T "meta_categories" }}: {{ range $index, $category := .Params.categories }}{{ if gt $index 0 }}, {{ end }}<a class="meta-categories__link" href="{{ "categories/" | relLangURL }}{{ . | urlize | lower }}" rel="category">{{ . }}</a>{{ end }}</span>
</span>
{{- end }}

View file

@ -0,0 +1,6 @@
{{- if not .Date.IsZero }}
<time class="post__meta-published meta-published" datetime="{{ .Date.Format "2006-01-02T15:04:05" }}">{{ .Date.Format ( .Site.Params.dateFormat | default "January 02, 2006" )}}</time>
{{- end }}
{{- if ne .Date .Lastmod }}
<time class="post__meta-lastmod meta-lastmod" datetime="{{ .Lastmod.Format "2006-01-02T15:04:05" }}">{{ T "meta_lastmod" }}: {{ .Lastmod.Format ( .Site.Params.dateFormat | default "January 02, 2006" )}}</time>
{{- end }}