Files
tsuki/layouts/_partials/toc-enabled.html
T
tiennm99 5d73a139ea refactor: consolidate TOC gate, inline single-call SEO partial, prune unused i18n
- Extract duplicated TOC predicate to _partials/toc-enabled.html
  (single.html + footer.html were both computing the same 6-line gate).
- Inline _partials/head/og-image.html into head/seo.html — single caller,
  the fallback chain is the contract; the partial wasn't earning its
  override surface.
- Drop 6 unused i18n keys: postedOn, tags, categories, archive, noResults,
  copyright. None referenced by any template (verified via grep). Also
  removed an accidental duplicate of the callout title block; vi.yml
  reorganized into thematic groups.

Behavior unchanged. Smoke (11 checks) + Hugo build clean. CSS bundle
unchanged at 3962 B gz.
2026-05-09 09:45:57 +07:00

14 lines
632 B
HTML

{{- /*
Single source of truth for whether to render the TOC for the current page.
Returns the literal string "true" when enabled, empty otherwise.
Callers: `single.html` (TOC partial), `footer.html` (toc-active.js loader).
Site config: `params.toc.enable` (default true), `params.toc.minWordCount` (default 400).
Per-page override: frontmatter `toc: false` always wins.
*/ -}}
{{- $cfg := site.Params.toc | default dict -}}
{{- $enabled := $cfg.enable | default true -}}
{{- $min := $cfg.minWordCount | default 400 -}}
{{- if and $enabled (eq .Kind "page") (gt .WordCount $min) (ne .Params.toc false) -}}
true
{{- end -}}