Make post meta fields configurable
This commit is contained in:
parent
982b2eae26
commit
228a06dc5f
4 changed files with 20 additions and 12 deletions
|
@ -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
|
||||||
|
|
|
@ -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 }}
|
|
5
layouts/partials/post_meta/categories.html
Normal file
5
layouts/partials/post_meta/categories.html
Normal 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 }}
|
6
layouts/partials/post_meta/date.html
Normal file
6
layouts/partials/post_meta/date.html
Normal 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 }}
|
Loading…
Reference in a new issue