From 10130c4963ff38cadbefa2f4597b6caf2cb95b37 Mon Sep 17 00:00:00 2001 From: Hanwen Guo Date: Sat, 27 Aug 2022 21:24:22 +0800 Subject: [PATCH] clean structure of layouts/ and add support for taxonomys --- layouts/_default/baseof.html | 2 +- layouts/_default/taxonomy.html | 8 ++++++++ layouts/_default/term.html | 8 ++++++++ layouts/baseof.html | 13 ------------- layouts/partials/menu_item.html | 10 +++++----- layouts/partials/post_list.html | 12 ++++++++++-- layouts/shortcodes/hr.html | 13 ------------- 7 files changed, 32 insertions(+), 34 deletions(-) create mode 100644 layouts/_default/taxonomy.html create mode 100644 layouts/_default/term.html delete mode 100644 layouts/baseof.html delete mode 100644 layouts/shortcodes/hr.html diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 3cbef52..207a4f2 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -1,5 +1,5 @@ - + {{- partial "head.html" . -}}
diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html new file mode 100644 index 0000000..a1ecdc4 --- /dev/null +++ b/layouts/_default/taxonomy.html @@ -0,0 +1,8 @@ +{{ define "main" }} +{{ partial "back_link.html" .}} + +

{{ .Title }}

+ +{{ .Content }} +{{ partial "post_list.html" (dict "context" .)}} +{{ end }} diff --git a/layouts/_default/term.html b/layouts/_default/term.html new file mode 100644 index 0000000..a1ecdc4 --- /dev/null +++ b/layouts/_default/term.html @@ -0,0 +1,8 @@ +{{ define "main" }} +{{ partial "back_link.html" .}} + +

{{ .Title }}

+ +{{ .Content }} +{{ partial "post_list.html" (dict "context" .)}} +{{ end }} diff --git a/layouts/baseof.html b/layouts/baseof.html deleted file mode 100644 index bedcbb4..0000000 --- a/layouts/baseof.html +++ /dev/null @@ -1,13 +0,0 @@ - - - {{- partial "head.html" . -}} - -
-
- {{- block "main" . }}{{- end }} - -
-
- - - diff --git a/layouts/partials/menu_item.html b/layouts/partials/menu_item.html index d0bc1f6..2603551 100644 --- a/layouts/partials/menu_item.html +++ b/layouts/partials/menu_item.html @@ -8,6 +8,10 @@ {{- end -}} + {{- if $item.entries }} + {{ partial "menu_item.html" (dict "context" . "collection" $item.entries) }} + {{- end -}} + {{- if $item.post_list -}} {{ partial "post_list.html" (dict "context" . @@ -18,9 +22,5 @@ "show_more_url" $item.post_list.show_more_url ) -}} {{- end -}} - - {{- if $item.entries }} - {{ partial "menu_item.html" (dict "context" . "collection" $item.entries) }} - {{- end -}} {{- end -}} - \ No newline at end of file + diff --git a/layouts/partials/post_list.html b/layouts/partials/post_list.html index 09f1222..22a35b6 100644 --- a/layouts/partials/post_list.html +++ b/layouts/partials/post_list.html @@ -3,7 +3,15 @@ {{- if .section -}} {{- $posts = (where site.RegularPages "Section" .section) -}} {{- else -}} - {{- $posts = site.RegularPages }} + {{- if (eq .context.Kind "taxonomy") -}} + {{- $posts = .context.Pages -}} + {{- else -}} + {{- if (eq .context.Kind "term") -}} + {{- $posts = .context.Data.Pages -}} + {{- else -}} + {{- $posts = site.RegularPages }} + {{- end -}} + {{- end -}} {{- end -}} {{- $limit_exceeded:= "" -}} @@ -28,4 +36,4 @@
  • {{ .show_more_text | default "Show more..." }}
  • {{ end }} -{{ end }} \ No newline at end of file +{{ end }} diff --git a/layouts/shortcodes/hr.html b/layouts/shortcodes/hr.html deleted file mode 100644 index 89f6c54..0000000 --- a/layouts/shortcodes/hr.html +++ /dev/null @@ -1,13 +0,0 @@ -{{ if .IsNamedParams }} - {{ with .Get "text" }} -
    - {{ else }} -
    - {{ end }} -{{ else }} - {{ with .Get 0 }} -
    - {{ else }} -
    - {{ end }} -{{ end }} \ No newline at end of file