Site: sidebar level-4 headings.

Fixes #2389
pull/2390/head
Luca Bonavita 6 years ago
parent ade0bc870a
commit 010a784b4e

@ -106,6 +106,10 @@
opacity: 1 opacity: 1
} }
.subsection[data-level="4"] {
padding-left: 1em;
}
.active { .active {
opacity: 1; opacity: 1;
/* font-weight: 700; */ /* font-weight: 700; */
@ -138,7 +142,12 @@
{#each section.subsections as subsection} {#each section.subsections as subsection}
<!-- see <script> below: on:click='scrollTo(event, subsection.slug)' --> <!-- see <script> below: on:click='scrollTo(event, subsection.slug)' -->
<a class="subsection" class:active="{subsection.slug === active_section}" href="docs#{subsection.slug}"> <a
class="subsection"
class:active="{subsection.slug === active_section}"
href="docs#{subsection.slug}"
data-level="{subsection.level}"
>
{subsection.title} {subsection.title}
{#if subsection.slug === active_section} {#if subsection.slug === active_section}
@ -150,4 +159,4 @@
{/each} {/each}
</li> </li>
{/each} {/each}
</ul> </ul>

@ -109,7 +109,7 @@ export default function() {
if (seen.has(slug)) throw new Error(`Duplicate slug ${slug}`); if (seen.has(slug)) throw new Error(`Duplicate slug ${slug}`);
seen.add(slug); seen.add(slug);
if (level === 3) { if (level === 3 || level === 4) {
const title = unescape( const title = unescape(
text text
.replace(/<\/?code>/g, '') .replace(/<\/?code>/g, '')
@ -120,12 +120,12 @@ export default function() {
}) })
); );
subsections.push({ slug, title }); subsections.push({ slug, title, level });
} }
return ` return `
<h${level}> <h${level}>
<span id="${slug}" class="offset-anchor" ${level > 3 ? 'data-scrollignore' : ''}></span> <span id="${slug}" class="offset-anchor"></span>
<a href="docs#${slug}" class="anchor" aria-hidden="true"></a> <a href="docs#${slug}" class="anchor" aria-hidden="true"></a>
${text} ${text}
</h${level}>`; </h${level}>`;

@ -18,8 +18,7 @@
let show_contents = false; let show_contents = false;
onMount(() => { onMount(() => {
// don't update `active_section` for headings below level 3, see _sections.js const anchors = container.querySelectorAll('[id]');
const anchors = container.querySelectorAll('[id]:not([data-scrollignore])');
let positions; let positions;

Loading…
Cancel
Save