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

Patrick Kollitsch
23 hours ago d343f0b8575a02a872f4cfbde314da4d0b60b53c
feat: make section link above article title clickable and configurable

The `article/section-link` hook now renders the section label as a link
instead of plain text. By default it points to the section index page
(`_index.md`).

A new `ananke.section_link` parameter (page front matter or site params)
controls the target:

- unset (default): the section index page
- "first": the first page of the section, honouring its sort order
- "<path>": a specific page, resolved relative to the section

Unresolvable values fall back to the section index. The visible label
remains the section title.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 files modified
33 ■■■■■ changed files
layouts/_partials/hooks/article/section-link.html 33 ●●●●● patch | view | raw | blame | history
layouts/_partials/hooks/article/section-link.html
@@ -1,3 +1,30 @@
<aside class="instapaper_ignoref b helvetica tracked ttu">
    {{ .CurrentSection.Title }}
</aside>
{{- /*
  Renders the section label above the article title, linked to a page within
  the section. The link target is controlled by the `ananke.section_link`
  parameter (page front matter, or site params for a site-wide default):
    - unset (default): the section index page (its `_index.md`)
    - "first":         the first page of the section, honouring its sort order
    - "<path>":        a specific page, resolved relative to the section
                       (e.g. "introduction" or "/about")
  The visible label is always the section title; only the destination changes.
*/ -}}
{{- with .CurrentSection -}}
  {{- $section := . -}}
  {{- $target := $section -}}
  {{- with $.Param "ananke.section_link" -}}
    {{- if eq . "first" -}}
      {{- with first 1 $section.RegularPages -}}
        {{- $target = index . 0 -}}
      {{- end -}}
    {{- else -}}
      {{- with $section.GetPage . -}}
        {{- $target = . -}}
      {{- end -}}
    {{- end -}}
  {{- end -}}
  <aside class="instapaper_ignoref b helvetica tracked ttu">
    <a class="link dim" href="{{ $target.Permalink }}">{{ $section.Title }}</a>
  </aside>
{{- end -}}