Skip to content

Commit e354cb6

Browse files
committed
chore: docs, handbok, 404 page
- Condense left-hand nav #417 - Hide TOC in handbook if empty - Buttons 404 page
1 parent 3e9ad30 commit e354cb6

File tree

5 files changed

+66
-52
lines changed

5 files changed

+66
-52
lines changed

astro.config.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,38 +109,47 @@ export default defineConfig({
109109
{
110110
label: 'Datum Documentation',
111111
autogenerate: { directory: 'docs/overview' },
112+
collapsed: false, // First group is expanded by default
112113
},
113114
{
114115
label: 'Quickstart',
115116
autogenerate: { directory: 'docs/quickstart' },
117+
collapsed: true, // All other groups are collapsed by default
116118
},
117119
{
118120
label: 'Platform',
119121
autogenerate: { directory: 'docs/platform' },
122+
collapsed: true,
120123
},
121124
{
122125
label: 'API',
123126
autogenerate: { directory: 'docs/api' },
127+
collapsed: true,
124128
},
125129
{
126130
label: 'Runtime',
127131
autogenerate: { directory: 'docs/runtime' },
132+
collapsed: true,
128133
},
129134
{
130135
label: 'Workflows',
131136
autogenerate: { directory: 'docs/workflows' },
137+
collapsed: true,
132138
},
133139
{
134140
label: 'Assets',
135141
autogenerate: { directory: 'docs/assets' },
142+
collapsed: true,
136143
},
137144
{
138145
label: 'For Alt Clouds',
139146
autogenerate: { directory: 'docs/alt-cloud' },
147+
collapsed: true,
140148
},
141149
{
142150
label: 'Guides',
143151
autogenerate: { directory: 'docs/guides' },
152+
collapsed: true,
144153
},
145154
{
146155
label: 'Glossary',

src/components/TableOfContents.astro

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ const {
1313
const filteredHeadings = headings.filter((heading: MarkdownHeading) => heading.depth <= 3);
1414
---
1515

16-
<aside class={`toc-container ${className || ''} ${sticky ? 'sticky top-0' : ''}`}>
17-
{showTitle && <h3 class="toc-title">{title}</h3>}
18-
19-
{
20-
filteredHeadings.length > 0 ? (
16+
{
17+
filteredHeadings.length > 0 && (
18+
<aside class={`toc-container ${className || ''} ${sticky ? 'sticky top-0' : ''}`}>
19+
{showTitle && <h3 class="toc-title">{title}</h3>}
2120
<nav class={`toc-nav`}>
2221
<ul class="toc-list">
2322
{filteredHeadings.map((heading: MarkdownHeading) => (
@@ -29,54 +28,52 @@ const filteredHeadings = headings.filter((heading: MarkdownHeading) => heading.d
2928
))}
3029
</ul>
3130
</nav>
32-
) : (
33-
<div class="toc-empty">
34-
<p>No table of contents available</p>
35-
</div>
36-
)
37-
}
38-
</aside>
31+
</aside>
32+
)
33+
}
3934

4035
<script>
41-
// Add active link highlighting based on scroll position
42-
function updateActiveTOCLink() {
36+
// Check if TOC exists before running the script
37+
document.addEventListener('DOMContentLoaded', () => {
4338
const tocLinks = document.querySelectorAll('.toc-link');
44-
const sections = document.querySelectorAll('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]');
39+
if (tocLinks.length === 0) return;
4540

46-
let current = '';
41+
// Add active link highlighting based on scroll position
42+
function updateActiveTOCLink() {
43+
const sections = document.querySelectorAll('h1[id], h2[id], h3[id], h4[id], h5[id], h6[id]');
44+
let current = '';
4745

48-
sections.forEach((section) => {
49-
const element = section as HTMLElement;
50-
const sectionTop = element.offsetTop;
51-
if (window.scrollY >= sectionTop - 200) {
52-
current = section.getAttribute('id') || '';
53-
}
54-
});
46+
sections.forEach((section) => {
47+
const element = section as HTMLElement;
48+
const sectionTop = element.offsetTop;
49+
if (window.scrollY >= sectionTop - 200) {
50+
current = section.getAttribute('id') || '';
51+
}
52+
});
5553

56-
tocLinks.forEach((link) => {
57-
link.classList.remove('active');
58-
if (link.getAttribute('href') === `#${current}`) {
59-
link.classList.add('active');
60-
}
61-
});
62-
}
54+
tocLinks.forEach((link) => {
55+
link.classList.remove('active');
56+
if (link.getAttribute('href') === `#${current}`) {
57+
link.classList.add('active');
58+
}
59+
});
60+
}
6361

64-
// Throttle scroll events
65-
let ticking = false;
66-
function requestTick() {
67-
if (!ticking) {
68-
requestAnimationFrame(updateActiveTOCLink);
69-
ticking = true;
62+
// Throttle scroll events
63+
let ticking = false;
64+
function requestTick() {
65+
if (!ticking) {
66+
requestAnimationFrame(updateActiveTOCLink);
67+
ticking = true;
68+
}
7069
}
71-
}
7270

73-
function handleScroll() {
74-
ticking = false;
75-
requestTick();
76-
}
71+
function handleScroll() {
72+
ticking = false;
73+
requestTick();
74+
}
7775

78-
// Add scroll listener and initialize
79-
document.addEventListener('DOMContentLoaded', () => {
76+
// Initialize and add scroll listener
8077
updateActiveTOCLink();
8178
window.addEventListener('scroll', handleScroll);
8279
});

src/components/starlight/TableOfContents.astro

Whitespace-only changes.

src/pages/404.astro

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import '@v1/styles/global.css';
55
import Layout from '@layouts/Layout.astro';
66
import Hero from '@components/Hero.astro';
77
import Footer from '@components/Footer.astro';
8+
import Button from '@components/Button.astro';
89
import Image404 from '@v1/assets/images/404.png';
9-
import Icon from '@components/Icon.astro';
1010
import { Image } from 'astro:assets';
1111
1212
const title = "Sorry, we can't find that page";
@@ -22,14 +22,18 @@ const description = 'The page you are looking for does not exist.';
2222
<Image src={Image404} alt="404" class="mx-auto mb-12 h-auto w-full max-w-[423px]" />
2323
<article class="prose prose-xl mx-auto text-center">
2424
<p class="mb-12">Please check the URL and try again.</p>
25-
<a href="/" class="btn btn--glacier-mist-700 btn--large mr-1">
26-
Return to homepage
27-
<Icon name="arrow-right" size="md" />
28-
</a>
29-
<a href="/docs/" class="btn btn--glacier-mist-700 btn--large ml-1">
30-
Browse our Docs
31-
<Icon name="arrow-right" size="md" />
32-
</a>
25+
<Button
26+
text="Return to homepage"
27+
href="/"
28+
class="btn btn--alpha mr-1"
29+
icon={{ name: 'arrow-right', size: 'md' }}
30+
/>
31+
<Button
32+
text="Browse our Docs"
33+
href="/docs/"
34+
class="btn btn--alpha ml-1"
35+
icon={{ name: 'arrow-right', size: 'md' }}
36+
/>
3337
</article>
3438
</main>
3539
</div>

src/v1/styles/components-handbook.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@
4444

4545
.handbook-toc {
4646
@apply border-glacier-mist-900 relative hidden w-full flex-col gap-y-4 border-l-1 pt-9 pb-12 pl-7 md:mb-0 md:max-w-60.25 lg:flex;
47+
48+
.article-aside {
49+
@apply mb-6;
50+
}
4751
}
4852

4953
.handbook-toc .toc-container {

0 commit comments

Comments
 (0)