Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toc fix #1880

Merged
merged 2 commits into from
Mar 26, 2025
Merged

Toc fix #1880

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions src/lib/components/blog/table-of-contents.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<script lang="ts" context="module">
export type TocItem = {
title: string;
href: string;
step?: number;
selected?: boolean;
level?: number;
children?: Array<{
title: string;
href: string;
selected: boolean;
level?: number;
}>;
};
</script>

<script lang="ts">
import type { TocItem } from '$lib/layouts/DocsArticle.svelte';
import { classNames } from '$lib/utils/classnames';
import { fade } from 'svelte/transition';

Expand All @@ -9,14 +24,16 @@

let isScrolled: boolean = false;

window.addEventListener('scroll', () => {
const handleIsScrolled = () => {
isScrolled = !!window.scrollY;
});
};

export let toc: Array<TocItem> = [];
export let heading: string = 'Table of Contents';
</script>

<svelte:window on:scroll={handleIsScrolled} />

<nav class="sticky top-32 col-span-3 mt-2 -ml-4 hidden h-[800px] flex-col gap-6 lg:flex">
<span class="text-micro tracking-loose text-primary font-aeonik-fono ps-6 uppercase"
>{heading}</span
Expand Down
1 change: 0 additions & 1 deletion src/lib/layouts/DocsArticle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import { setContext } from 'svelte';
import { writable } from 'svelte/store';
import { Feedback } from '$lib/components';
import { scrollToTop } from '$lib/actions/scrollToTop';
import TableOfContents from '$lib/components/blog/table-of-contents.svelte';

export let title: string;
Expand Down
Loading