mirror of https://github.com/theNewDynamic/gohugo-theme-ananke.git

Patrick Kollitsch
4 days ago a58a496fd284622dcde608218dfac4d4d35f20cb
feat: add layout and content hook points

Wire the hook.html system into the base layout and single templates so site
projects can inject or filter markup without overriding templates. Adds the
positional hooks head-end, body-start, header-before, header-after,
main-before, main-after, footer-before, footer-after and body-end in
baseof.html (head-end via head-additions.html), plus content-before and
content-after around the article content in single.html and page/single.html.

Each hook is a no-op until a site provides the matching
layouts/_partials/hooks/<name>.html partial.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
4 files modified
20 ■■■■■ changed files
layouts/_partials/head-additions.html 8 ●●●●● patch | view | raw | blame | history
layouts/baseof.html 8 ●●●●● patch | view | raw | blame | history
layouts/page/single.html 2 ●●●●● patch | view | raw | blame | history
layouts/single.html 2 ●●●●● patch | view | raw | blame | history
layouts/_partials/head-additions.html
@@ -0,0 +1,8 @@
{{- /*
  head-additions.html — the designated injection point at the end of <head>.
  Site projects can override this partial directly, or use the "head-end" hook
  to inject markup (meta tags, preloads, third-party <script>/<link> tags)
  without overriding the partial. See the documentation on hooks & filters.
*/ -}}
{{- partials.Include "hook.html" (dict "hook" "head-end" "context" .) -}}
layouts/baseof.html
@@ -72,11 +72,19 @@
  {{- if .IsSection -}}{{- $body_classes = $body_classes | append "is-section" -}}{{- end -}}
  <body class="{{ delimit $body_classes " " }}">
    {{- partials.Include "hook.html" (dict "hook" "body-start" "context" .) -}}
    {{- partials.Include "hook.html" (dict "hook" "header-before" "context" .) -}}
    {{ block "header" . }}{{ partials.Include "site-header.html" .}}{{ end }}
    {{- partials.Include "hook.html" (dict "hook" "header-after" "context" .) -}}
    <main class="pb7" role="main">
      {{- partials.Include "hook.html" (dict "hook" "main-before" "context" .) -}}
      {{ block "main" . }}{{ end }}
      {{- partials.Include "hook.html" (dict "hook" "main-after" "context" .) -}}
    </main>
    {{- partials.Include "hook.html" (dict "hook" "footer-before" "context" .) -}}
    {{ block "footer" . }}{{ partials.IncludeCached "site-footer.html" . }}{{ end }}
    {{- partials.Include "hook.html" (dict "hook" "footer-after" "context" .) -}}
    {{- partials.Include "hook.html" (dict "hook" "body-end" "context" .) -}}
  </body>
</html>
{{- with (templates.Defer (dict "key" "hooks-collector")) -}}
layouts/page/single.html
@@ -14,7 +14,9 @@
        </h1>
      </header>
      <div class="nested-copy-line-height lh-copy f4 nested-links {{ $.Param "text_color" | compare.Default "mid-gray" }}">
        {{- partials.Include "hook.html" (dict "hook" "content-before" "context" .) -}}
        {{ .Content }}
        {{- partials.Include "hook.html" (dict "hook" "content-after" "context" .) -}}
      </div>
    </article>
  </div>
layouts/single.html
@@ -72,7 +72,9 @@
      {{ end }}
    </header>
    <div class="nested-copy-line-height lh-copy {{ $.Param "post_content_classes"  | compare.Default "serif"}} f4 nested-links {{ $.Param "text_color" | compare.Default "mid-gray" }} {{ compare.Conditional (compare.Eq $.Site.Language.Direction "rtl") "pl4-l" "pr4-l" }} {{ if $needs_aside }}w-two-thirds-l{{ else }}w-100-l{{ end }}">
      {{- partials.Include "hook.html" (dict "hook" "content-before" "context" .) -}}
      {{- .Content -}}
      {{- partials.Include "hook.html" (dict "hook" "content-after" "context" .) -}}
      {{- partials.Include "tags.html" . -}}
      {{ if .Site.Config.Services.Disqus.Shortname }}
      <div class="mt6 instapaper_ignoref">