aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Toc.svelte
blob: 190c6a4ab25ce74f2964c19e7d2a129247ce4936 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<script lang="ts">
	import { cleanId } from './utils'

	export let categories: string[]
</script>

<ul id="toc">
	<h3>Contents</h3>
	{#each categories as category}
		<li><a href="#{category}">{cleanId(category)}</a></li>
	{/each}
</ul>

<style>
	#toc {
		border: 1px solid rgba(255, 255, 255, 0.1);
		max-width: max-content;
		padding: 0.75em;
		border-radius: 1em;

		display: inline-block;
		background: rgba(0, 0, 0, 0.1);
	}
	#toc li {
		list-style-type: none;
	}
</style>