Skip to content

Commit 0cad7f4

Browse files
caugnerOnkarRuikar
andauthored
fix(docs): restore behavior of description term links (#9811)
#8413 introduced a regression, making it hard to identify description terms (`<dt>`) that link to another page. This restores the style of those links, excluding anchor links, and also makes the hashtag of the anchor links interactive. Co-authored-by: Onkar Ruikar <[email protected]>
1 parent d640774 commit 0cad7f4

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

Diff for: client/src/document/index.scss

+19-20
Original file line numberDiff line numberDiff line change
@@ -145,32 +145,31 @@
145145
margin-bottom: 0.5rem;
146146
margin-top: 2rem;
147147

148-
a {
149-
&:link,
150-
&:visited {
151-
color: inherit;
152-
text-decoration: none;
153-
}
148+
a[href^="#"] {
149+
color: inherit;
150+
position: relative;
151+
text-decoration: none;
154152

155153
&:hover,
156154
&:focus {
157155
text-decoration: underline;
158156
}
159157

160-
&[href^="#"] {
161-
position: relative;
162-
163-
&:hover::before {
164-
color: var(--text-inactive);
165-
content: "#";
166-
display: inline-flex;
167-
font-size: 0.7em;
168-
left: -0.75em;
169-
line-height: 1;
170-
position: absolute;
171-
text-decoration: none;
172-
top: 0.5em;
173-
}
158+
&::before {
159+
color: var(--text-inactive);
160+
content: "#";
161+
display: inline-flex;
162+
font-size: 0.7em;
163+
line-height: 1;
164+
margin-left: -0.8em;
165+
text-decoration: none;
166+
top: 0.5em;
167+
visibility: hidden;
168+
width: 0.8em;
169+
}
170+
171+
&:hover::before {
172+
visibility: visible;
174173
}
175174
}
176175
}

Diff for: kumascript/src/api/util.ts

+5
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ export class HTMLTool {
224224
$element.attr("id", id);
225225

226226
if (isDt) {
227+
// Remove empty anchor links.
228+
// This happens if the term already links to a page.
229+
$element.find("a[data-link-to-id = true]:empty").remove();
230+
231+
// Link remaining anchor links to the term's ID.
227232
$element
228233
.find("a[data-link-to-id = true]")
229234
.attr("href", "#" + id)

0 commit comments

Comments
 (0)