Skip to content

Commit 5a9707e

Browse files
F OpenNebula/one#7635: Add anchor links to all headings (#645)
This PR introduces an anchor link for headings of all levels, such that developers can easily send clients links to specific documentation sections, including those that are below the heading level displayed in the right hand TOC.
1 parent 89097d4 commit 5a9707e

3 files changed

Lines changed: 44 additions & 0 deletions

File tree

assets/scss/_styles_project.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@import "image/_styles_project_image.scss";
1515
@import "dashboard/_styles_project_dashboard.scss";
1616
@import "search-docs/_styles_project_search_docs.scss";
17+
@import "heading/styles_project_heading.scss";
1718
@import "_styles_fonts";
1819

1920
/**
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Styles for heading anchor links (h1-h6)
2+
.td-content {
3+
.anchor-link {
4+
visibility: hidden !important;
5+
opacity: 0 !important;
6+
margin-left: 0.4rem;
7+
font-size: 0.8em;
8+
text-decoration: none !important;
9+
transition: opacity 0.2s ease-in-out, color 0.2s ease;
10+
11+
/* Light mode default color */
12+
color: rgba(0, 0, 0, 0.3) !important;
13+
}
14+
15+
/* Target headers explicitly within the content area */
16+
h1, h2, h3, h4, h5, h6 {
17+
&:hover .anchor-link {
18+
visibility: visible !important;
19+
opacity: 1 !important;
20+
}
21+
}
22+
23+
/* Hover state for the link itself */
24+
.anchor-link:hover {
25+
color: #007bff !important;
26+
}
27+
}
28+
29+
// Dark mode overrides
30+
html[data-bs-theme="dark"] .td-content {
31+
.anchor-link {
32+
color: rgba(255, 255, 255, 0.3) !important;
33+
}
34+
.anchor-link:hover {
35+
color: #4dabff !important;
36+
}
37+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
2+
{{ .Text | safeHTML }}
3+
<a class="anchor-link" href="#{{ .Anchor | safeURL }}" aria-label="Link to this section">
4+
<i class="fas fa-link fa-xs"></i>
5+
</a>
6+
</h{{ .Level }}>

0 commit comments

Comments
 (0)