Skip to content

Commit

Permalink
fix: save external slide (slidevjs#1111)
Browse files Browse the repository at this point in the history
  • Loading branch information
KermanX committed Feb 16, 2024
1 parent 9dbe3ae commit 89d5cad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/parser/src/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export async function save(data: SlidevMarkdown, filepath?: string) {
await fs.writeFile(filepath, stringify(data), 'utf-8')
}

export async function saveExternalSlide(slide: SlideInfoWithPath) {
await fs.writeFile(slide.filepath, stringifySlide(slide), 'utf-8')
export async function saveExternalSlide(data: SlidevMarkdown, filepath: string) {
const slides = data.slides.map(s => s.source).filter(s => s?.filepath === filepath)
await fs.writeFile(filepath, stringify({ slides } as any), 'utf-8')
}
2 changes: 1 addition & 1 deletion packages/slidev/node/plugins/loaders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export function createSlidesLoader(

if (slide.source) {
Object.assign(slide.source, body)
await parser.saveExternalSlide(slide.source)
await parser.saveExternalSlide(data, slide.source.filepath)
}
else {
Object.assign(slide, body)
Expand Down

0 comments on commit 89d5cad

Please sign in to comment.