File tree 3 files changed +12
-8
lines changed
3 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { resolveOptions } from './options'
20
20
import { parser } from './parser'
21
21
import { getRoots , isInstalledGlobally , resolveEntry } from './resolver'
22
22
import setupPreparser from './setups/preparser'
23
+ import { updateFrontmatterPatch } from './utils'
23
24
24
25
const CONFIG_RESTART_FIELDS : ( keyof SlidevConfig ) [ ] = [
25
26
'monaco' ,
@@ -420,17 +421,19 @@ cli.command(
420
421
}
421
422
const [ name , root ] = ( await resolveTheme ( themeRaw , entry ) ) as [ string , string ]
422
423
424
+ await fs . mkdir ( path . resolve ( dir ) , { recursive : true } )
423
425
await fs . cp (
424
426
root ,
425
427
path . resolve ( dir ) ,
426
428
{
427
- filter : i => ! / n o d e _ m o d u l e s | .g i t / . test ( path . relative ( root , i ) ) ,
429
+ recursive : true ,
430
+ filter : i => ! / n o d e _ m o d u l e s | \. g i t / . test ( path . relative ( root , i ) ) ,
428
431
} ,
429
432
)
430
433
431
434
const dirPath = `./${ dir } `
432
435
const firstSlide = data . entry . slides [ 0 ]
433
- firstSlide . frontmatter . theme = dirPath
436
+ updateFrontmatterPatch ( firstSlide , { theme : dirPath } )
434
437
parser . prettifySlide ( firstSlide )
435
438
await parser . save ( data . entry )
436
439
Original file line number Diff line number Diff line change 1
- import type { ResolvedFontOptions , SlideInfo } from '@slidev/types'
1
+ import type { ResolvedFontOptions , SourceSlideInfo } from '@slidev/types'
2
2
import type MarkdownIt from 'markdown-it'
3
3
import type { Connect } from 'vite'
4
4
import { fileURLToPath } from 'node:url'
@@ -48,15 +48,14 @@ export function generateCoollabsFontsUrl(options: ResolvedFontOptions) {
48
48
/**
49
49
* Update frontmatter patch and preserve the comments
50
50
*/
51
- export function updateFrontmatterPatch ( slide : SlideInfo , frontmatter : Record < string , any > ) {
52
- const source = slide . source
51
+ export function updateFrontmatterPatch ( source : SourceSlideInfo , frontmatter : Record < string , any > ) {
53
52
let doc = source . frontmatterDoc
54
53
if ( ! doc ) {
55
54
source . frontmatterStyle = 'frontmatter'
56
55
source . frontmatterDoc = doc = new YAML . Document ( { } )
57
56
}
58
57
for ( const [ key , value ] of Object . entries ( frontmatter ) ) {
59
- slide . frontmatter [ key ] = source . frontmatter [ key ] = value
58
+ source . frontmatter [ key ] = value
60
59
if ( value == null ) {
61
60
doc . delete ( key )
62
61
}
Original file line number Diff line number Diff line change @@ -107,8 +107,10 @@ export function createSlidesLoader(
107
107
}
108
108
if ( body . note )
109
109
slide . note = slide . source . note = body . note
110
- if ( body . frontmatter )
111
- updateFrontmatterPatch ( slide , body . frontmatter )
110
+ if ( body . frontmatter ) {
111
+ updateFrontmatterPatch ( slide . source , body . frontmatter )
112
+ Object . assign ( slide . frontmatter , body . frontmatter )
113
+ }
112
114
113
115
parser . prettifySlide ( slide . source )
114
116
const fileContent = await parser . save ( data . markdownFiles [ slide . source . filepath ] )
You can’t perform that action at this time.
0 commit comments