slidev-addon-counter
v0.2.1
Published
Multi-level counters for Slidev.
Readme
slidev-addon-counter
English | 中文
Multi-level counters for Slidev, useful for chapter, section, theorem, and other reusable numbers.
Requirements
- Node.js >= 22.18.0
- Slidev >= 52.0.0
Install
pnpm add -D slidev-addon-counterEnable the addon in your Slidev deck frontmatter:
addons:
- slidev-addon-counterQuick Examples
Default Counter
Components without id use the built-in default counter. The addon provides it automatically, even when you configure other counters:
# <Counter /> Introduction
## <Counter :level="2" /> Background
Current section: <CounterDisplay :level="2" />Configured Counter
Create slidev-addon-counter.config.ts next to your Slidev entry file:
import { defineCounterConfig } from "slidev-addon-counter/config";
export default defineCounterConfig({
counters: [
{
id: "section",
defaultLevel: "section",
levels: [
{
level: 1,
alias: "chapter",
},
{
level: 2,
alias: "section",
},
],
},
],
});Use the configured aliases and default level in slides:
# <Counter id="section" level="chapter" /> Introduction
## <Counter id="section" /> Background
Current section: <CounterDisplay id="section" />More Examples
The live demo shows richer examples with the config, slide source, and rendered output side by side.
You can also read the complete demo source in demo/.
Manual
See the user manual for full configuration, format syntax, component behavior, and common patterns.
Development
source ~/.nvm/nvm.sh
nvm use
pnpm install
pnpm checkPreview the local demo:
pnpm dev