Skip to content

Commit 762ec01

Browse files
authored
Add hashtag to headings (#229)
* feat: Add hashtag to headings * fix: Text is now clickable * fix: Removed unneeded link styling
1 parent 713be80 commit 762ec01

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

assets/css/v2/style.css

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,75 @@ h2 {
10071007
margin: 1rem 0 .75rem 0;
10081008
}
10091009

1010+
h2:target,
1011+
h3:target,
1012+
h4:target,
1013+
h5:target,
1014+
h6:target {
1015+
color: var(--color-brand);
1016+
1017+
.headerlink::before {
1018+
display: block !important;
1019+
}
1020+
}
1021+
1022+
h2:has(a),
1023+
h3:has(a),
1024+
h4:has(a),
1025+
h5:has(a),
1026+
h6:has(a) {
1027+
width: calc(100% + 1rem);
1028+
margin-left: -1rem;
1029+
padding-left: 1rem;
1030+
position: relative;
1031+
}
1032+
1033+
h2:has(a):hover {
1034+
.headerlink::before {
1035+
display: block;
1036+
}
1037+
}
1038+
1039+
h3:has(a):hover {
1040+
.headerlink::before {
1041+
display: block;
1042+
}
1043+
}
1044+
1045+
h4:has(a):hover {
1046+
.headerlink::before {
1047+
display: block;
1048+
}
1049+
}
1050+
1051+
h5:has(a):hover {
1052+
.headerlink::before {
1053+
display: block;
1054+
}
1055+
}
1056+
1057+
h6:has(a):hover {
1058+
.headerlink::before {
1059+
display: block;
1060+
}
1061+
}
1062+
1063+
.headerlink {
1064+
text-decoration: none;
1065+
1066+
color: black;
1067+
}
1068+
1069+
.headerlink::before {
1070+
position: absolute;
1071+
content: "#";
1072+
margin-left: -1.5rem;
1073+
opacity: 20%;
1074+
display: none;
1075+
bottom: 0;
1076+
color: oklch(var(--color-brand));
1077+
}
1078+
10101079
/* MARK: Tables
10111080
*/
10121081
table {
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
<h{{ .Level }}
2-
id="{{ .Anchor | safeURL }}">{{ .Text | safeHTML }} <a class="headerlink float-right" href="#{{ .Anchor | safeURL }}" title="{{ .Text | safeHTML }}"><i class="fas fa-link fa-xs"></i></a>
2+
id="{{ .Anchor | safeURL }}">
3+
<div data-mf="false">
4+
{{ .Text | safeHTML }}
5+
<a class="headerlink float-right" href="#{{ .Anchor | safeURL }}" title="{{ .Text | safeHTML }}">
6+
<i class="fas fa-link fa-xs"></i>
7+
</a>
8+
</div>
9+
10+
<a class="headerlink float-right" data-mf="true" style="display: none;" href="#{{ .Anchor | safeURL }}" title="{{ .Text | safeHTML }}">
11+
{{ .Text | safeHTML }}
12+
</a>
313
</h{{ .Level }}>

0 commit comments

Comments
 (0)