Display table of contents on right side

This commit is contained in:
thiloho
2024-08-25 19:32:57 +02:00
parent 8ea7f7b4a3
commit 0753345bba
2 changed files with 23 additions and 9 deletions

View File

@@ -124,10 +124,12 @@ const createMarkdownParser = (showToc = true) => {
} }
tableOfContents = ` tableOfContents = `
<details class="table-of-contents"> <section id="table-of-contents">
<summary>Table of contents</summary> <h2>
<a href="#table-of-contents">Table of contents</a>
</h2>
${tocItems.join("")} ${tocItems.join("")}
</details> </section>
`; `;
} }

View File

@@ -34,10 +34,10 @@ footer {
} }
.articles ul { .articles ul {
display: grid; display: flex;
flex-direction: column;
list-style: none; list-style: none;
gap: var(--space-s); gap: var(--space-s);
grid-template-columns: repeat(auto-fit, minmax(min(100%, 30ch), 1fr));
} }
.articles li { .articles li {
@@ -48,10 +48,22 @@ footer {
gap: var(--space-xs); gap: var(--space-xs);
} }
.table-of-contents {
margin-block-end: var(--space-s);
}
section { section {
scroll-margin-block-start: var(--space-xl); scroll-margin-block-start: var(--space-xl);
} }
@media (min-width: 1525px) {
#table-of-contents {
position: fixed;
inset-inline-start: calc(50% + 37.5ch + var(--space-m));
inset-block-start: calc(var(--space-xl) + var(--space-s));
max-inline-size: 35ch;
padding: var(--space-s);
background-color: var(--bg-primary);
border: var(--border-primary);
}
#table-of-contents + section {
margin-block-start: 0;
}
}