Skip to content

Commit 984a607

Browse files
authored
Merge pull request #606 from HIMU-2001/heading-permalinks
Implemented Heading Permalinks with Hover/Visible Chain Icon #596
2 parents e426142 + a9815dc commit 984a607

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

assets/scss/_elements_project.scss

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,26 @@ div.tip {
149149
font-size: 1rem;
150150
font-weight: 600;
151151
word-break: break-word;
152-
}
152+
}
153+
154+
.heading-link {
155+
position: relative;
156+
display: flex;
157+
align-items: center;
158+
gap: 0.3rem;
159+
160+
.heading-anchor {
161+
font-size: 0.6em;
162+
opacity: 0;
163+
transform: translateY(2px);
164+
transition: opacity 0.3s ease, transform 0.3s ease;
165+
margin-left: 0.25rem;
166+
text-decoration: none;
167+
}
168+
169+
&:hover .heading-anchor {
170+
opacity: 1;
171+
transform: translateY(0);
172+
}
173+
}
174+

assets/scss/_styles_project.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
@import "_videos_project.scss";
1212
@import "subscription.scss";
1313
@import "_video-landing_project.scss";
14+
@import "elements_project";
1415

1516
.navbar-dark {
1617
min-height: 5rem;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{- $level := .Level -}}
2+
{{- $text := .Text | safeHTML -}}
3+
{{- $anchor := .Anchor | safeURL -}}
4+
5+
{{ $level := .Level }}
6+
<h{{ $level }} id="{{ .Anchor | safeURL }}" class="heading-link">
7+
{{ .Text }}
8+
<a href="#{{ .Anchor | safeURL }}" class="heading-anchor" aria-label="Permalink to this heading">🔗</a>
9+
</h{{ $level }}>

0 commit comments

Comments
 (0)