slidev
slidev copied to clipboard
Table of contents and sections
Is your feature request related to a problem? Please describe.
I would like to generate a table of contents automatically rather than making this page manually, this would be helpful for some high-logic slides.
Describe the solution you'd like
We may need to introduce the concept of sections, which can be used as logic units for slides, and table of contents can be generated by the sections and subsections and even subsubsections. Refer to the LaTeX Beamer package for a similar design.
Describe alternatives you've considered
Maybe multiple entrances can be utilized to achieve a similar result, but that enforces splitting files and can be inconvenient sometimes.
This could be done on the user side by creating a component with the Vue context: https://sli.dev/custom/vue-context.html
An minimal example:
<template v-for="route of $slidev.nav.rawRoutes">
<a :href="route.path">{{route.meta.title}}</a>
</template>
BTW, is there a way to automatically add page numbers to all slides? For example, "current/total" in the lower right corner.
BTW, is there a way to automatically add page numbers to all slides? For example, "current/total" in the lower right corner.
You can add a global-bottom.vue, see https://sli.dev/custom/global-layers.html.
<template> <footer v-if="$slidev.nav.currentLayout !== 'cover'" class="absolute bottom-0 right-0 p-2 text-teal-900" > {{ $slidev.nav.currentPage }} / {{ $slidev.nav.total }} </footer></template>
The <Toc/> component is now available: https://sli.dev/builtin/components.html#toc
Closing this issue. If the solution does not satisfy your needs, please reopen it.
I wonder how the cover page can be hidden from the TOC: https://github.com/slidevjs/slidev/discussions/1123
@louwers The frontmatter at the top of your document is used for both:
- global settings
- page settings for the first slide
So just put hideInToc: true in the top frontmatter bloc