RenderHooks: Reconfigure the heading hashes
Instead of a single hash in the left gutter, draw <n> hashes where <n> is the heading level. All of these hashes are part of the anchor text.
This commit is contained in:
parent
c30805127c
commit
cce432fe0b
2 changed files with 33 additions and 6 deletions
|
@ -41,4 +41,28 @@
|
||||||
.content-date {
|
.content-date {
|
||||||
margin-block-end: var(--space-paragraph);
|
margin-block-end: var(--space-paragraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.heading {
|
||||||
|
display: block flex;
|
||||||
|
gap: var(--space-s);
|
||||||
|
grid-column: main-start / main-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading__anchor {
|
||||||
|
align-self: center;
|
||||||
|
color: var(--gray5);
|
||||||
|
font-size: var(--text-m);
|
||||||
|
justify-content: center;
|
||||||
|
letter-spacing: -0.2em;
|
||||||
|
|
||||||
|
a {
|
||||||
|
transition: 0.3s color;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: var(--text-color);
|
||||||
|
text-decoration: none;
|
||||||
|
transition: 0.3s color;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
<h{{ .Level }} id="{{ .Anchor }}" class="heading">
|
{{- $pageWantsAnchors := .Page.Params.renderHeadingAnchors | default true -}}
|
||||||
{{ .Text | safeHTML }}
|
{{- $anchorEnabledForThisHeading := .Attributes.anchor | default true -}}
|
||||||
{{- $pageWantsAnchors := .Page.Params.renderHeadingAnchors | default true -}}
|
{{- $hasAnchor := and $pageWantsAnchors $anchorEnabledForThisHeading -}}
|
||||||
{{- $anchorEnabledForThisHeading := .Attributes.anchor | default true -}}
|
<h{{ .Level }} id="{{ .Anchor }}" class="heading{{ if $hasAnchor }} with-anchor{{ end }}">
|
||||||
{{- if and $pageWantsAnchors $anchorEnabledForThisHeading -}}
|
{{- if $hasAnchor -}}
|
||||||
<a class="heading__anchor" href="#{{ .Anchor }}">#</a>
|
<span class="heading__anchor">
|
||||||
|
<a href="#{{ .Anchor }}">{{ range seq .Level }}#{{ end }}</a>
|
||||||
|
</span>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
{{ .Text | safeHTML }}
|
||||||
</h{{ .Level }}>
|
</h{{ .Level }}>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue