theme: fix id generation for markdownified titles #657

This commit is contained in:
Sören Weber 2023-09-30 21:45:39 +02:00
parent 5342161fed
commit e090fc89c0
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
13 changed files with 16 additions and 16 deletions

View file

@ -5,7 +5,7 @@
{{- range .Data.Terms.Alphabetical }}
{{- $capital := substr .Page.Title 0 1 | upper }}
{{- if ne $lastCapital $capital }}
<li><a href="#{{ $capital | anchorize }}">{{ $capital }}</a></li>
<li><a href="#{{ $capital | plainify | anchorize }}">{{ $capital }}</a></li>
{{- end }}
{{- $lastCapital = $capital }}
{{- end }}

View file

@ -67,7 +67,7 @@
<div class="flex-block-wrapper">
<article>
<h1 id="404"><span>4</span>{{ partial "shortcodes/icon.html" (dict "page" . "icon" "far fa-frown" )}}<span>4</span></h1>
<h2 id="{{ T "title-404" | anchorize }}">{{ T "title-404" }}</h2>
<h2 id="{{ T "title-404" | plainify | anchorize }}">{{ T "title-404" }}</h2>
<p></p>
<p>{{ T "message-404" }}</p>
<p></p>

View file

@ -9,7 +9,7 @@
{{- if not $title }}
{{- $title = .Data.Plural }}
{{- end }}
<h1 id="{{ $title | anchorize }}">{{ $title }}</h1>
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
{{- $lastCapital := "" }}
{{- range .Data.Terms.Alphabetical }}
{{- $capital := substr .Page.Title 0 1 | upper }}
@ -17,7 +17,7 @@
{{- if ne $lastCapital "" }}
</ul>
{{- end }}
<h2 id="{{ $capital | anchorize }}">{{ $capital }}</h2>
<h2 id="{{ $capital | plainify | anchorize }}">{{ $capital }}</h2>
<ul class="columnize">
{{- end }}
{{- $c:=""}}{{/* display terms of a taxonomy */}}

View file

@ -10,7 +10,7 @@
{{- $title = .Data.Singular }}
{{- end }}
{{- $title = printf "%s %s %s" $title (default "::" .Site.Params.titleSeparator) .Title }}
<h1 id="{{ $title | anchorize }}">{{ $title }}</h1>
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
<ul class="columnize">
{{- range sort .Pages "Title" }}
{{- $c:=""}}{{/* display pages of a term */}}

View file

@ -6,7 +6,7 @@
{{- partial "content-header.html" . }}
</header>
{{ partial "heading-pre.html" . }}<div class="article-subheading">{{ T "Chapter" .Params.Weight }}</div>
<h1 id="{{ .Title | anchorize }}">{{ .Title }}</h1>{{ partial "heading-post.html" . }}
<h1 id="{{ .Title | plainify | anchorize }}">{{ .Title }}</h1>{{ partial "heading-post.html" . }}
{{ $content | safeHTML }}
<footer class="footline">

View file

@ -5,7 +5,7 @@
<header class="headline">
{{- partial "content-header.html" . }}
</header>
{{ partial "heading-pre.html" . }}<h1 id="{{ .Title | anchorize }}">{{ .Title }}</h1>{{ partial "heading-post.html" . }}
{{ partial "heading-pre.html" . }}<h1 id="{{ .Title | plainify | anchorize }}">{{ .Title }}</h1>{{ partial "heading-post.html" . }}
{{ $content | safeHTML }}
<footer class="footline">

View file

@ -5,7 +5,7 @@
<header class="headline">
{{- partial "content-header.html" . }}
</header>
{{ partial "heading-pre.html" . }}<h1 id="{{ .Title | anchorize }}">{{ .Title }}</h1>{{ partial "heading-post.html" . }}
{{ partial "heading-pre.html" . }}<h1 id="{{ .Title | plainify | anchorize }}">{{ .Title }}</h1>{{ partial "heading-post.html" . }}
{{ $content | safeHTML }}
<footer class="footline">

View file

@ -3,7 +3,7 @@
<article class="default">
<header class="headline">
</header>
<h1 id="{{ $title | anchorize }}">{{ $title }}</h1>
<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>
<form action="javascript:triggerSearch()">
<div class="searchform">

View file

@ -9,7 +9,7 @@
<i class='fas fa-list'></i>
{{- $categories := slice | append .Params.categories }}
{{- range $idx, $category := sort $categories }}
{{- with $page.Site.GetPage (printf "%s%s" ("/categories/" | relURL ) ( $category | anchorize ) ) }}
{{- with $page.Site.GetPage (printf "%s%s" ("/categories/" | relURL ) ( $category | plainify | anchorize ) ) }}
{{- $to := . }}
{{ if gt $idx 0 }} | {{ end }}<a class="tag-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $category }}</a>
{{- end }}

View file

@ -1,6 +1,6 @@
{{- if not .Title }}
{{- $title := .Site.Title }}
{{- partial "heading-pre.html" . }}<h1 id="{{ $title | anchorize }}">{{ $title }}</h1>{{ partial "heading-post.html" . }}
{{- partial "heading-pre.html" . }}<h1 id="{{ $title | plainify | anchorize }}">{{ $title }}</h1>{{ partial "heading-post.html" . }}
{{- end }}
{{- "layouts/partials/initial.md" | readFile | .RenderString }}

View file

@ -3,7 +3,7 @@
{{- $page = .context }}
{{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'tabs' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration/#5180" $page.File.Path }}
{{- end }}
{{- $groupid := .groupid | default (partial "make-random-md5.hugo" $page) | anchorize }}
{{- $groupid := .groupid | default (partial "make-random-md5.hugo" $page) | plainify | anchorize }}
{{- $color := .color }}
{{- $style := .style }}
{{- $title := .title }}
@ -34,7 +34,7 @@
"color" $color
"content" .content
"icon" $icon
"itemid" (printf "%s%s" ($title | $page.RenderString | anchorize) ($icon | anchorize))
"itemid" (printf "%s%s" ($title | $page.RenderString | plainify | anchorize) ($icon | plainify | anchorize))
"style" $style
"title" $title
) }}

View file

@ -5,7 +5,7 @@
{{- $tags := slice | append .Params.tags }}
{{- range sort $tags }}
{{- $tag := . }}
{{- with $page.Site.GetPage (printf "%s%s" ("/tags/" | relURL ) ( $tag | anchorize ) ) }}
{{- with $page.Site.GetPage (printf "%s%s" ("/tags/" | relURL ) ( $tag | plainify | anchorize ) ) }}
{{- $to := . }}
<a class="tag-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $tag }}</a>
{{- end }}

View file

@ -5,7 +5,7 @@
{{- range .Data.Terms.Alphabetical }}
{{- $capital := substr .Page.Title 0 1 | upper }}
{{- if ne $lastCapital $capital }}
<li><a href="#{{ $capital | anchorize }}">{{ $capital }}</a></li>
<li><a href="#{{ $capital | plainify | anchorize }}">{{ $capital }}</a></li>
{{- end }}
{{- $lastCapital = $capital }}
{{- end }}