diff --git a/themes/tsuki/exampleSite/hugo.yaml b/themes/tsuki/exampleSite/hugo.yaml index c72582c..1069cb5 100644 --- a/themes/tsuki/exampleSite/hugo.yaml +++ b/themes/tsuki/exampleSite/hugo.yaml @@ -29,6 +29,18 @@ markup: startLevel: 2 endLevel: 4 +related: + threshold: 80 + includeNewer: true + toLower: true + indices: + - name: tags + weight: 100 + - name: categories + weight: 60 + - name: date + weight: 10 + params: description: Example site for the tsuki Hugo theme. diff --git a/themes/tsuki/hugo.yaml b/themes/tsuki/hugo.yaml index 5a4113b..4f6d49c 100644 --- a/themes/tsuki/hugo.yaml +++ b/themes/tsuki/hugo.yaml @@ -1,6 +1,21 @@ languageCode: vi defaultContentLanguage: vi +module: + mounts: + - source: archetypes + target: archetypes + - source: assets + target: assets + - source: data + target: data + - source: i18n + target: i18n + - source: layouts + target: layouts + - source: static + target: static + pagination: pagerSize: 10 path: page @@ -25,6 +40,18 @@ markup: startLevel: 2 endLevel: 4 +related: + threshold: 80 + includeNewer: true + toLower: true + indices: + - name: tags + weight: 100 + - name: categories + weight: 60 + - name: date + weight: 10 + params: search: enable: true @@ -34,3 +61,4 @@ params: toc: enable: true minWordCount: 400 + relatedPostsCount: 3 diff --git a/themes/tsuki/layouts/_partials/related-posts.html b/themes/tsuki/layouts/_partials/related-posts.html new file mode 100644 index 0000000..adc66e1 --- /dev/null +++ b/themes/tsuki/layouts/_partials/related-posts.html @@ -0,0 +1,20 @@ +{{- /* + Related posts for single pages. Uses Hugo's built-in `Related` keyword index. + Requires `related:` config in site hugo.yaml — see docs/config.md. + Silently no-op when no relations are found. +*/ -}} +{{- $count := site.Params.relatedPostsCount | default 3 -}} +{{- $related := slice -}} +{{- if gt $count 0 -}} + {{- $related = first $count (site.RegularPages.Related .) -}} +{{- end -}} +{{- with $related -}} + +{{- end -}}