Skip to content

Commit f378385

Browse files
authored
feat: add article.headingAnchor parameter and use CSS pseudo-element to display # symbol of heading anchor (#1016)
* feat: add `article.headingAnchor` parameter * feat: use CSS pseudo-element to display `#` symbol of heading anchor This prevents RSS feed readers and screen readers from seeing an extra `#`. * Deactivate `article.headingAnchor` by default
1 parent 130e2f6 commit f378385

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

assets/scss/partials/layout/article.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@
232232
width: var(--card-padding);
233233
text-align: center;
234234
color: var(--accent-color);
235+
236+
&:before {
237+
content: "#";
238+
}
235239
}
236240

237241
&:hover,

config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ params:
2828
src: img/avatar.png
2929

3030
article:
31+
headingAnchor: false
3132
math: false
3233
toc: true
3334
readingTime: true
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<h{{ .Level }} id="{{ .Anchor }}">
2-
<a href="#{{ .Anchor }}" class="header-anchor">#</a>
2+
{{- if site.Params.Article.HeadingAnchor -}}
3+
<a href="#{{ .Anchor }}" class="header-anchor"></a>
4+
{{- end -}}
35
{{ .Text | safeHTML }}
46
</h{{ .Level }}>

0 commit comments

Comments
 (0)