Skip to content

Commit 2b2c2bc

Browse files
authored
Merge pull request #484 from raifdmueller/fix/doc-page-anchor-links
fix(doc-page): restore deep-link scrolling and show AsciiDoc section anchor icons
2 parents 41d856d + eb770e4 commit 2b2c2bc

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

website/src/components/doc-page.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ export async function loadDocContent(docPath) {
6464
// Attach click-to-load handlers for any YouTube placeholders in the doc.
6565
// Keeps us DSGVO-compliant: YouTube is only contacted after user consent.
6666
hydrateYouTubeFacades(contentEl)
67+
68+
// Restore deep-link scrolling: if the URL has a hash (e.g. #phase-0-5),
69+
// the browser tried to scroll there before the SPA replaced #doc-content
70+
// with this newly fetched HTML. Re-scroll to the target now that the
71+
// section exists in the DOM.
72+
if (window.location.hash) {
73+
const id = decodeURIComponent(window.location.hash.slice(1))
74+
const target = document.getElementById(id)
75+
if (target) {
76+
target.scrollIntoView({ behavior: 'auto', block: 'start' })
77+
}
78+
}
6779
} catch (error) {
6880
console.error('Failed to load documentation:', error)
6981
contentEl.innerHTML = `

website/src/styles/main.css

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,3 +520,56 @@ body {
520520
height: 100%;
521521
border: 0;
522522
}
523+
524+
/* AsciiDoc section anchors: visible chain icon on hover, like the default
525+
Asciidoctor stylesheet. Asciidoctor renders <a class="anchor" href="#id">
526+
before each heading when sectanchors:true is set in render-docs.js. */
527+
.asciidoc-content h1,
528+
.asciidoc-content h2,
529+
.asciidoc-content h3,
530+
.asciidoc-content h4,
531+
.asciidoc-content h5,
532+
.asciidoc-content h6 {
533+
position: relative;
534+
scroll-margin-top: 5rem;
535+
}
536+
537+
.asciidoc-content h1 > a.anchor,
538+
.asciidoc-content h2 > a.anchor,
539+
.asciidoc-content h3 > a.anchor,
540+
.asciidoc-content h4 > a.anchor,
541+
.asciidoc-content h5 > a.anchor,
542+
.asciidoc-content h6 > a.anchor {
543+
position: absolute;
544+
left: -1.25rem;
545+
top: 0;
546+
bottom: 0;
547+
display: flex;
548+
align-items: center;
549+
width: 1.25rem;
550+
opacity: 0;
551+
text-decoration: none;
552+
color: var(--color-text-secondary, #6b7280);
553+
transition: opacity 0.15s ease-in-out;
554+
}
555+
556+
.asciidoc-content h1:hover > a.anchor,
557+
.asciidoc-content h2:hover > a.anchor,
558+
.asciidoc-content h3:hover > a.anchor,
559+
.asciidoc-content h4:hover > a.anchor,
560+
.asciidoc-content h5:hover > a.anchor,
561+
.asciidoc-content h6:hover > a.anchor,
562+
.asciidoc-content a.anchor:focus {
563+
opacity: 1;
564+
}
565+
566+
.asciidoc-content a.anchor::before {
567+
content: '\00a7'; /* § — same convention as the default Asciidoctor stylesheet */
568+
font-size: 0.85em;
569+
font-weight: normal;
570+
}
571+
572+
.asciidoc-content a.anchor:hover {
573+
color: var(--color-link, #2563eb);
574+
text-decoration: none;
575+
}

0 commit comments

Comments
 (0)