slidev icon indicating copy to clipboard operation
slidev copied to clipboard

Table of contents and sections

Open Ahacad opened this issue 4 years ago • 4 comments

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.

Ahacad avatar May 30 '21 14:05 Ahacad

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>

antfu avatar Jun 03 '21 13:06 antfu

BTW, is there a way to automatically add page numbers to all slides? For example, "current/total" in the lower right corner.

mozhewen avatar Nov 15 '21 19:11 mozhewen

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>

Ahacad avatar Nov 20 '21 05:11 Ahacad

The <Toc/> component is now available: https://sli.dev/builtin/components.html#toc

tonai avatar May 24 '22 16:05 tonai

Closing this issue. If the solution does not satisfy your needs, please reopen it.

tonai avatar Jan 23 '23 15:01 tonai

I wonder how the cover page can be hidden from the TOC: https://github.com/slidevjs/slidev/discussions/1123

louwers avatar Sep 13 '23 22:09 louwers

@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

tonai avatar Sep 14 '23 12:09 tonai