Skip to content

feat: Add built-in audience-based slide filtering via showFor/hideFor frontmatter #2636

Description

@L-C-P

Problem Statement

When presenting to different audiences (e.g., developers, architects, managers, clients), it would be useful to selectively show or hide slides without maintaining separate slide decks or using external build scripts.

Currently, Slidev's preparser system (setup/preparser.ts) allows custom filtering, but there is no built-in solution for audience-based slide visibility.

Proposed Solution

Add native support for two new frontmatter fields:

  • showFor – Comma-separated list or array of audiences that should see this slide
  • hideFor – Comma-separated list or array of audiences that should NOT see this slide

The active audience would be specified via:

  1. Environment variable AUDIENCE (CLI override, highest priority)
  2. Headmatter audience field in slides.md

When no audience is configured, all slides remain visible (backward compatible).

Example Usage

---
layout: default
showFor: devs, architects
---

# Technical Deep Dive

This slide is only visible when `AUDIENCE=devs` or `AUDIENCE=architects`.
---
layout: default
hideFor: managers
---

# Implementation Details

This slide is hidden when `AUDIENCE=managers`.
# Run with specific audience
AUDIENCE=devs slidev
AUDIENCE=managers slidev build

Reference Implementation

I've implemented this as a project-local preparser extension and it works well. The key aspects:

  • Uses existing definePreparserSetup hook
  • Leverages frontmatter.disabled to hide slides
  • Supports both comma-separated strings and arrays
  • Case-insensitive audience matching
  • No audience set = all slides visible (backward compatible)

I'm happy to implement this

I already have a working reference implementation and would be glad to contribute a PR for this feature — either way you prefer:

Option A: Built-in integration

  • Core preparser integration in @slidev/parser
  • Documentation update for sli.dev
  • Tests for the new frontmatter fields and environment variable handling

Option B: Official Slidev Addon

  • I publish it as slidev-addon-audience-filter on npm
  • Add it to the Addon Gallery
  • Maintained independently but following Slidev conventions

Either way, you would have no work to do — I'll handle the implementation and maintenance. Just let me know which approach aligns better with the project's direction and I'll get started!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions