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

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@
{{- partial "content-header.html" . }} {{- partial "content-header.html" . }}
</header> </header>
{{ partial "heading-pre.html" . }}<div class="article-subheading">{{ T "Chapter" .Params.Weight }}</div> {{ 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 }} {{ $content | safeHTML }}
<footer class="footline"> <footer class="footline">

View file

@ -5,7 +5,7 @@
<header class="headline"> <header class="headline">
{{- partial "content-header.html" . }} {{- partial "content-header.html" . }}
</header> </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 }} {{ $content | safeHTML }}
<footer class="footline"> <footer class="footline">

View file

@ -5,7 +5,7 @@
<header class="headline"> <header class="headline">
{{- partial "content-header.html" . }} {{- partial "content-header.html" . }}
</header> </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 }} {{ $content | safeHTML }}
<footer class="footline"> <footer class="footline">

View file

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

View file

@ -9,7 +9,7 @@
<i class='fas fa-list'></i> <i class='fas fa-list'></i>
{{- $categories := slice | append .Params.categories }} {{- $categories := slice | append .Params.categories }}
{{- range $idx, $category := sort $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 := . }} {{- $to := . }}
{{ if gt $idx 0 }} | {{ end }}<a class="tag-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $category }}</a> {{ if gt $idx 0 }} | {{ end }}<a class="tag-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $category }}</a>
{{- end }} {{- end }}

View file

@ -1,6 +1,6 @@
{{- if not .Title }} {{- if not .Title }}
{{- $title := .Site.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 }} {{- end }}
{{- "layouts/partials/initial.md" | readFile | .RenderString }} {{- "layouts/partials/initial.md" | readFile | .RenderString }}

View file

@ -3,7 +3,7 @@
{{- $page = .context }} {{- $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 }} {{- 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 }} {{- end }}
{{- $groupid := .groupid | default (partial "make-random-md5.hugo" $page) | anchorize }} {{- $groupid := .groupid | default (partial "make-random-md5.hugo" $page) | plainify | anchorize }}
{{- $color := .color }} {{- $color := .color }}
{{- $style := .style }} {{- $style := .style }}
{{- $title := .title }} {{- $title := .title }}
@ -34,7 +34,7 @@
"color" $color "color" $color
"content" .content "content" .content
"icon" $icon "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 "style" $style
"title" $title "title" $title
) }} ) }}

View file

@ -5,7 +5,7 @@
{{- $tags := slice | append .Params.tags }} {{- $tags := slice | append .Params.tags }}
{{- range sort $tags }} {{- range sort $tags }}
{{- $tag := . }} {{- $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 := . }} {{- $to := . }}
<a class="tag-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $tag }}</a> <a class="tag-link" href="{{ partial "relLangPrettyUglyURL.hugo" (dict "to" $to) }}">{{ $tag }}</a>
{{- end }} {{- end }}

View file

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