Skip to content

Commit

Permalink
feat: display header anchor on hover (CaiJimmy#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaiJimmy authored and albanpetit committed May 3, 2024
1 parent 780be20 commit 36d6f0d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions assets/scss/partials/layout/article.scss
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,24 @@
margin-inline-start: calc((var(--card-padding)) * -1);
padding-inline-start: calc(var(--card-padding) - var(--heading-border-size));
border-inline-start: var(--heading-border-size) solid var(--accent-color);
position: relative;

a.header-anchor {
transition: opacity 0.3s ease;
opacity: 0;
position: absolute;
left: 0;
width: var(--card-padding);
text-align: center;
color: var(--accent-color);
}

&:hover,
&:focus {
a.header-anchor {
opacity: 1;
}
}
}

figure {
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/_markup/render-heading.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h{{ .Level }} id="{{ .Anchor }}">
<a href="#{{ .Anchor }}">#</a>
<a href="#{{ .Anchor }}" class="header-anchor">#</a>
{{ .Text | safeHTML }}
</h{{ .Level }}>

0 comments on commit 36d6f0d

Please sign in to comment.