Skip to content

Commit

Permalink
Add heading anchors (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish authored Jun 5, 2024
1 parent e37612f commit b26d79f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
includes icons from the bootstrap project - discord and opencollective
includes icons from octicons (distributed under MIT license) - link
5 changes: 5 additions & 0 deletions layouts/_default/_markup/render-heading.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<a href="#{{ .Anchor | safeURL }}" class="anchor-wrapper">
<h{{ .Level }} id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }}
<span class="anchor-icon">{{ partial "svg/link.svg" }}</span>
</h{{ .Level }}>
</a>
22 changes: 22 additions & 0 deletions themes/mainroad/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,28 @@ summary code:hover {
}
}

.anchor-wrapper .anchor-icon {
visibility: hidden;
display: inline-block;
}

.anchor-wrapper * {
transition: none;
}

.anchor-wrapper .anchor-icon svg {
height: 0.75em;
width: 0.75em;
}

.anchor-wrapper:hover .anchor-icon, .anchor-wrapper:focus .anchor-icon {
visibility: visible;
}

a.anchor-wrapper:hover, a.anchor-wrapper:focus {
text-decoration: none;
}

[data-theme="light"] {
--color-highlight: #d7742f;
--color-background: #d5e0df;
Expand Down
4 changes: 4 additions & 0 deletions themes/mainroad/layouts/partials/colors.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ h6 {
color: var(--color-text);
}

.anchor-icon {
fill: var(--color-text);
}

a {
color: var(--color-text);
}
Expand Down
1 change: 1 addition & 0 deletions themes/mainroad/layouts/partials/svg/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b26d79f

Please sign in to comment.