Slidev Presentation Tool

repository·main·Indexed 13 days ago

https://github.com/slidevjs/slidev

A presentation tool for developers that uses Markdown to create high-quality, interactive slides. Built with Vite, Vue 3, and UnoCSS, it features built-in code highlighting, live coding, LaTeX math, Mermaid diagrams, and presenter mode. It supports exporting to PDF, PNG, and PPTX, and provides a dedicated parser via the @slidev/parser package.

Tokens
113K
Snippets
526
Records
646
Agent score
99%

What's inside Slidev

  1. Overview of Slidev features

    main

    Slidev is a presentation tool designed specifically for developers. Key capabilities include:

    • Markdown-based: Write content using Markdown syntax.
    • Developer-centric: Built-in code highlighting, live coding, and support for LaTeX math equations.
    • Interactive: Seamlessly embed Vue components and use UnoCSS for on-demand styling.
    • Visual Tools: Support for drawing/annotations, Mermaid diagrams, and Iconify icons.
    • Presenter Features: Presenter mode (remote control), built-in recording with camera view, and export options (PDF, PNG, PPTX).
    • Extensible: Powered by Vite, allowing the use of Vite plugins, Vue components, and any npm packages.
  2. Understand the Slidev conventional directory structure

    main

    Slidev uses a convention-over-configuration approach to minimize setup. While all directories are optional, following these patterns allows you to extend Slidev functionality intuitively without manual registration.

    Conventional Directory Structure

    your-slidev/
      ├── components/       # custom components
      ├── layouts/          # custom layouts
      ├── public/           # static assets
      ├── setup/            # custom setup / hooks
      ├── snippets/         # code snippets
      ├── styles/           # custom style
      ├── index.html        # injections to index.html
      ├── slides.md         # the main slides entry
      └── vite.config.ts    # extending vite config
  3. Use @slidev/parser to parse Slidev markdown

    main
    The @slidev/parser package is the core engine used to parse Markdown files specifically formatted for Slidev. It converts Slidev-flavored Markdown into a structured format that the Slidev engine can use to render slides. For detailed information on the specific Markdown syntax supported, refer to the Slidev Syntax Guide. For programmatic usage, consult the TypeScript definitions provided in the package.
  4. Core concepts and advantages of Slidev

    main

    Slidev is a Markdown-based, web-based presentation tool designed specifically for developers. It allows you to focus on content using an extended Markdown format while leveraging web technologies for high interactivity.

    Key Mental Models:

    • Markdown-First: Organize slides in a single plain text file, making them compatible with Git and any text editor.
    • Progressive Enhancement: Start with simple Markdown and add complexity (Vue components, themes, addons) only when needed.
    • Web-Powered: Since it is built on Vite, you can use anything available in a web app (WebGL, API requests, iframes) directly within your slides.
    • Developer-Centric: Features first-class support for code snippets via Shiki, live coding with Monaco Editor, and interactive Vue components.
  5. What the Slidev skill provides to Claude Code

    main

    The Slidev skill equips Claude Code with domain-specific knowledge required to generate and manipulate Slidev presentations, including:

    • Core Syntax: Markdown syntax, slide separators (---), and frontmatter.
    • Animations: Click animations, transitions, and motion effects.
    • Code Features: Line highlighting, Monaco editor integration, code groups, and magic-move.
    • Diagrams: Support for Mermaid, PlantUML, and LaTeX math.
    • Layouts: Built-in layouts, slots, and global layers.
    • Presenter Mode: Recording, timers, and remote access.
    • Exporting: Capabilities for PDF, PPTX, PNG, and SPA hosting.
  6. Animate code with Shiki Magic Move

    main

    To create smooth transitions between different states of a code block, wrap multiple code blocks within a magic-move container using four backticks (md magic-move). Slidev will animate the changes in code structure and content between the blocks.

    ```ts {*|2|*}
    // step 1
    const author = reactive({ ... })
    ```
    
    ```ts {*|1-2|3-4|3-4,8}
    // step 2
    export default { ... }
    ```
  7. Extend Slidev with Vue components and UnoCSS

    main

    Slidev is highly expressive due to its integration with modern web frameworks:

    • Vue Components: You can write and use Vue components directly in your slides to create interactive elements that you can manipulate during a presentation.
    • UnoCSS: Slidev comes with UnoCSS out of the box, allowing you to style your slides using atomic CSS.
    • Vite-based HMR: Changes made in your editor are updated in the browser instantly via Vite's Hot Module Replacement (HMR).
  8. How to use internal UI components in Slidev

    main
    Slidev provides built-in UI components for various interface elements. Unlike standard Slidev components, these internal components are not available via auto-import. To use them within your own custom components or slides, you must explicitly import them from the @slidev/client package.
  9. How the Slidev parsing process works

    main

    Slidev processes your presentation file (e.g., slides.md) in three distinct stages:

    1. Preparsing: The file is split into individual slides using the --- separator, while also considering frontmatter blocks.
    2. Markdown Parsing: Each individual slide is parsed using an external markdown library.
    3. Source Resolution: Slidev resolves the special src: .... frontmatter property, which allows you to include content from other .md files.

    Note: If you need to customize the markdown parser used in step 2, you must configure the Vite internal plugins.

  10. Understand the results of ejecting a theme

    main

    When you run slidev theme eject, the following changes occur in your project:

    1. File Extraction: The theme files are copied from node_modules into a new ./theme/ directory in your project root.
    2. Configuration Update: The theme field in your project's frontmatter is automatically updated to point to the local path: theme: ./theme.

    Note: If you are creating a derivative theme, it is recommended to credit the original theme and its author.

  11. Configure slides with Headmatter and Frontmatter

    main

    Slidev uses YAML blocks delimited by --- to configure the presentation and individual slides.

    • Headmatter: The very first YAML block in your entry Markdown file (e.g., slides.md). It configures the entire slide deck (e.g., theme, title).
    • Frontmatter: YAML blocks placed at the beginning of individual slides. These configure settings specific to that slide (e.g., layout, background, class).

    Note: You can also use an external file as a slide by using the src key in the frontmatter.

    ---
    theme: seriph
    title: Welcome to Slidev
    ---
    
    # Slide 1
    
    ---
    
    layout: center
    background: /background-1.png
    class: text-white
    ---
    
    # Slide 2
    
    ---
    
    src: ./pages/4.md
    ---
    
    # Slide 3