Skip to content

fix(client): use slide-local nav during export#2681

Open
NgoQuocViet2001 wants to merge 1 commit into
slidevjs:mainfrom
NgoQuocViet2001:fix/2670-export-nav-context
Open

fix(client): use slide-local nav during export#2681
NgoQuocViet2001 wants to merge 1 commit into
slidevjs:mainfrom
NgoQuocViet2001:fix/2670-export-nav-context

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown
Contributor

Description

During PDF/browser export, every slide is rendered at once under /export. PrintSlideClick already provides a fixed navigation context for each rendered slide, but the public useNav() composable always returned the application-wide shared nav instead. Components such as slide-top.vue therefore saw the route-level slide number (typically 1) on every exported page, and tocTree.active stayed fixed as well.

This change keeps the existing shared nav as the global source of router/print state, then overlays the nearest slide-local nav when a rendered slide provides one. Normal play/presenter views continue to receive the same shared nav object; export children receive their fixed currentSlideNo, currentSlideRoute, clicks, and TOC state while retaining the full nav API.

Tests

Added an SSR regression test that renders a child component under a slide-local export context while the global export route points at slide 1. It verifies that useNav() returns slide 2, its frontmatter, and the slide-2 active TOC entry.

  • pnpm exec vitest run packages/client — 5 passed
  • pnpm typecheck
  • targeted ESLint for the changed files
  • pnpm build

Closes #2670

@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit a196f62
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/6a61be18d94c5b0008681ad8
😎 Deploy Preview https://deploy-preview-2681--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Jul 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/@slidev/client@2681

create-slidev

npm i https://pkg.pr.new/create-slidev@2681

create-slidev-theme

npm i https://pkg.pr.new/create-slidev-theme@2681

@slidev/parser

npm i https://pkg.pr.new/@slidev/parser@2681

@slidev/cli

npm i https://pkg.pr.new/@slidev/cli@2681

@slidev/types

npm i https://pkg.pr.new/@slidev/types@2681

commit: a196f62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

useNav() returns stale values during PDF export

2 participants