Skip to content

Commit 2c860ee

Browse files
authored
fix: export respect page range (#2323)
1 parent 237a789 commit 2c860ee

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

packages/slidev/node/commands/export.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,17 @@ export async function exportSlides({
420420
await go('print')
421421
const slideContainers = page.locator('.print-slide-container')
422422
const count = await slideContainers.count()
423+
423424
for (let i = 0; i < count; i++) {
424-
progress.update(i + 1)
425425
const id = (await slideContainers.nth(i).getAttribute('id')) || ''
426426
const slideNo = +id.split('-')[0]
427+
428+
// Only process slides that are in the specified range
429+
if (!pages.includes(slideNo))
430+
continue
431+
432+
progress.update(result.length + 1)
433+
427434
const buffer = await slideContainers.nth(i).screenshot({
428435
omitBackground,
429436
})
@@ -476,12 +483,15 @@ export async function exportSlides({
476483

477484
async function genPageMd() {
478485
const pngs = await genPagePng(dirname(output))
479-
const content = slides.map(({ title, index, note }) =>
480-
pngs.filter(({ slideIndex }) => slideIndex === index)
481-
.map(({ filename }) => `![${title || (index + 1)}](./${filename})\n\n`)
482-
.join('')
483-
+ (note ? `${note.trim()}\n\n` : ''),
484-
).join('---\n\n')
486+
const content = slides
487+
.filter(({ index }) => pages.includes(index + 1))
488+
.map(({ title, index, note }) =>
489+
pngs.filter(({ slideIndex }) => slideIndex === index)
490+
.map(({ filename }) => `![${title || (index + 1)}](./${filename})\n\n`)
491+
.join('')
492+
+ (note ? `${note.trim()}\n\n` : ''),
493+
)
494+
.join('---\n\n')
485495
await fs.writeFile(ensureSuffix('.md', output), content)
486496
}
487497

0 commit comments

Comments
 (0)