From 228a06dc5f1e7b0f2cbd945e2f594d01dfd21983 Mon Sep 17 00:00:00 2001 From: vimux Date: Thu, 15 Nov 2018 14:21:34 -0500 Subject: [PATCH] Make post meta fields configurable --- README.md | 3 ++- layouts/partials/post_meta.html | 18 +++++++----------- layouts/partials/post_meta/categories.html | 5 +++++ layouts/partials/post_meta/date.html | 6 ++++++ 4 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 layouts/partials/post_meta/categories.html create mode 100644 layouts/partials/post_meta/date.html diff --git a/README.md b/README.md index f353961..4be9820 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,8 @@ googleAnalytics = "" # Enable Google Analytics by entering your tracking id twitter_cards = true # Enable Twitter Cards if true cardsPerRow = 2 # Possible values: 1, 2, 3 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 tocOpen = true # Open Table of Contents block. Optional comments = true # Enable comments for all site pages diff --git a/layouts/partials/post_meta.html b/layouts/partials/post_meta.html index dcd4bb9..81ecf40 100644 --- a/layouts/partials/post_meta.html +++ b/layouts/partials/post_meta.html @@ -1,11 +1,7 @@ -{{- if not .Date.IsZero }} - -{{ end }} -{{- if ne .Date .Lastmod }} - -{{- end }} -{{- if .Params.categories }} - - {{ T "meta_categories" }}: {{ range $index, $category := .Params.categories }}{{ if gt $index 0 }}, {{ end }}{{ . }}{{ end }} - -{{- end }} \ No newline at end of file +{{ $currentPage := . }} +{{- with .Param "post_meta" }} + {{- range $metaField := . -}} + {{- $metaFieldPath := printf "post_meta/%s.html" $metaField -}} + {{- partial $metaFieldPath $currentPage -}} + {{ end }} +{{ end }} \ No newline at end of file diff --git a/layouts/partials/post_meta/categories.html b/layouts/partials/post_meta/categories.html new file mode 100644 index 0000000..e2c7666 --- /dev/null +++ b/layouts/partials/post_meta/categories.html @@ -0,0 +1,5 @@ +{{- if .Params.categories }} + + {{ T "meta_categories" }}: {{ range $index, $category := .Params.categories }}{{ if gt $index 0 }}, {{ end }}{{ . }}{{ end }} + +{{- end }} \ No newline at end of file diff --git a/layouts/partials/post_meta/date.html b/layouts/partials/post_meta/date.html new file mode 100644 index 0000000..5d17cb3 --- /dev/null +++ b/layouts/partials/post_meta/date.html @@ -0,0 +1,6 @@ +{{- if not .Date.IsZero }} + +{{- end }} +{{- if ne .Date .Lastmod }} + +{{- end }} \ No newline at end of file