Skip to content

Commit 9dfa659

Browse files
authoredMar 26, 2025··
Merge pull request #1880 from appwrite/toc-fix
Toc fix
2 parents a39cbe2 + 8f215a5 commit 9dfa659

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed
 

‎src/lib/components/blog/table-of-contents.svelte

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1+
<script lang="ts" context="module">
2+
export type TocItem = {
3+
title: string;
4+
href: string;
5+
step?: number;
6+
selected?: boolean;
7+
level?: number;
8+
children?: Array<{
9+
title: string;
10+
href: string;
11+
selected: boolean;
12+
level?: number;
13+
}>;
14+
};
15+
</script>
16+
117
<script lang="ts">
2-
import type { TocItem } from '$lib/layouts/DocsArticle.svelte';
318
import { classNames } from '$lib/utils/classnames';
419
import { fade } from 'svelte/transition';
520
@@ -9,14 +24,16 @@
924
1025
let isScrolled: boolean = false;
1126
12-
window.addEventListener('scroll', () => {
27+
const handleIsScrolled = () => {
1328
isScrolled = !!window.scrollY;
14-
});
29+
};
1530
1631
export let toc: Array<TocItem> = [];
1732
export let heading: string = 'Table of Contents';
1833
</script>
1934

35+
<svelte:window on:scroll={handleIsScrolled} />
36+
2037
<nav class="sticky top-32 col-span-3 mt-2 -ml-4 hidden h-[800px] flex-col gap-6 lg:flex">
2138
<span class="text-micro tracking-loose text-primary font-aeonik-fono ps-6 uppercase"
2239
>{heading}</span

‎src/lib/layouts/DocsArticle.svelte

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import { setContext } from 'svelte';
1919
import { writable } from 'svelte/store';
2020
import { Feedback } from '$lib/components';
21-
import { scrollToTop } from '$lib/actions/scrollToTop';
2221
import TableOfContents from '$lib/components/blog/table-of-contents.svelte';
2322
2423
export let title: string;

0 commit comments

Comments
 (0)
Please sign in to comment.