Skip to content

Commit b6719fe

Browse files
committed
fix
1 parent 25201dc commit b6719fe

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

packages/parser/src/fs.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,15 @@ export async function load(userRoot: string, filepath: string, loadedSource: Rec
103103
}
104104
else {
105105
slides.push({
106-
...slide,
106+
frontmatter: { ...slide.frontmatter, ...frontmatterOverride },
107+
content: slide.content,
108+
frontmatterRaw: slide.frontmatterRaw,
109+
note: slide.note,
110+
title: slide.title,
111+
level: slide.level,
107112
index: slides.length,
108113
importChain,
109114
source: slide,
110-
frontmatter: { ...slide.frontmatter, ...frontmatterOverride },
111115
})
112116
}
113117
}

test/__snapshots__/parser.test.ts.snap

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ exports[`md parser > frontmatter.md > slides 1`] = `
8888
},
8989
"layout": "cover",
9090
},
91+
"frontmatterRaw": "layout: cover
92+
fonts:
93+
sans: Roboto, Lato
94+
serif: Mate SC
95+
mono: Fira Code
96+
",
9197
"importChain": undefined,
9298
"index": 0,
9399
"level": 1,
@@ -149,6 +155,11 @@ fonts:
149155
"title": "FooBar",
150156
},
151157
},
158+
"frontmatterRaw": "meta:
159+
title: FooBar
160+
duration: 12
161+
layout: center
162+
",
152163
"importChain": undefined,
153164
"index": 1,
154165
"level": 1,
@@ -204,6 +215,7 @@ This is note
204215
{
205216
"content": "# Morning",
206217
"frontmatter": {},
218+
"frontmatterRaw": undefined,
207219
"importChain": undefined,
208220
"index": 2,
209221
"level": 1,
@@ -236,6 +248,8 @@ Hey",
236248
"frontmatter": {
237249
"layout": "text",
238250
},
251+
"frontmatterRaw": "layout: text
252+
",
239253
"importChain": undefined,
240254
"index": 3,
241255
"level": undefined,
@@ -287,6 +301,7 @@ this should be treated as code block
287301
Also part of the code block
288302
\`\`\`",
289303
"frontmatter": {},
304+
"frontmatterRaw": undefined,
290305
"importChain": undefined,
291306
"index": 4,
292307
"level": undefined,
@@ -334,6 +349,10 @@ Also part of the code block
334349
"frontmatter": {
335350
"layout": "from yaml",
336351
},
352+
"frontmatterRaw": "
353+
# The first yaml block should be treated as frontmatter
354+
layout: from yaml
355+
",
337356
"importChain": undefined,
338357
"index": 5,
339358
"level": undefined,
@@ -381,6 +400,8 @@ Content 2",
381400
"frontmatter": {
382401
"layout": "cover",
383402
},
403+
"frontmatterRaw": "layout: cover
404+
",
384405
"importChain": undefined,
385406
"index": 6,
386407
"level": 1,
@@ -435,6 +456,7 @@ layout: should not from yaml 2
435456
436457
Content 3",
437458
"frontmatter": {},
459+
"frontmatterRaw": undefined,
438460
"importChain": undefined,
439461
"index": 7,
440462
"level": 1,
@@ -554,6 +576,8 @@ exports[`md parser > mdc.md > slides 1`] = `
554576
"frontmatter": {
555577
"mdc": true,
556578
},
579+
"frontmatterRaw": "mdc: true
580+
",
557581
"importChain": undefined,
558582
"index": 0,
559583
"level": 1,
@@ -674,6 +698,7 @@ Sample Text
674698
console.log('Hello World')
675699
\`\`\`",
676700
"frontmatter": {},
701+
"frontmatterRaw": undefined,
677702
"importChain": undefined,
678703
"index": 0,
679704
"level": 1,
@@ -724,6 +749,7 @@ console.log('Hello World')
724749
- Hey
725750
- Yo",
726751
"frontmatter": {},
752+
"frontmatterRaw": undefined,
727753
"importChain": undefined,
728754
"index": 1,
729755
"level": 1,
@@ -763,6 +789,7 @@ console.log('Hello World')
763789
{
764790
"content": "Nice to meet you",
765791
"frontmatter": {},
792+
"frontmatterRaw": undefined,
766793
"importChain": undefined,
767794
"index": 2,
768795
"level": undefined,
@@ -864,6 +891,7 @@ exports[`md parser > multi-entries.md > slides 1`] = `
864891
{
865892
"content": "# Page 1",
866893
"frontmatter": {},
894+
"frontmatterRaw": undefined,
867895
"importChain": [
868896
{
869897
"content": "",
@@ -939,6 +967,8 @@ src: sub/page1.md
939967
"background": "https://sli.dev/demo-cover.png#2",
940968
"layout": "cover",
941969
},
970+
"frontmatterRaw": "layout: cover
971+
",
942972
"importChain": [
943973
{
944974
"content": "",
@@ -1041,6 +1071,7 @@ layout: cover
10411071
"frontmatter": {
10421072
"background": "https://sli.dev/demo-cover.png#34",
10431073
},
1074+
"frontmatterRaw": undefined,
10441075
"importChain": [
10451076
{
10461077
"content": "",
@@ -1150,6 +1181,8 @@ background: https://sli.dev/demo-cover.png#34
11501181
"background": "https://sli.dev/demo-cover.png#34",
11511182
"layout": "cover",
11521183
},
1184+
"frontmatterRaw": "layout: cover
1185+
",
11531186
"importChain": [
11541187
{
11551188
"content": "",
@@ -1269,6 +1302,7 @@ layout: cover
12691302
"frontmatter": {
12701303
"background": "https://sli.dev/demo-cover.png#14",
12711304
},
1305+
"frontmatterRaw": undefined,
12721306
"importChain": [
12731307
{
12741308
"content": "",
@@ -1546,6 +1580,8 @@ src: /sub/page1.md
15461580
"background": "https://sli.dev/demo-cover.png#14",
15471581
"layout": "cover",
15481582
},
1583+
"frontmatterRaw": "layout: cover
1584+
",
15491585
"importChain": [
15501586
{
15511587
"content": "",
@@ -1846,6 +1882,7 @@ layout: cover
18461882
"frontmatter": {
18471883
"background": "https://sli.dev/demo-cover.png#14",
18481884
},
1885+
"frontmatterRaw": undefined,
18491886
"importChain": [
18501887
{
18511888
"content": "",
@@ -2153,6 +2190,8 @@ src: ../sub/pages3-4.md
21532190
"background": "https://sli.dev/demo-cover.png#14",
21542191
"layout": "cover",
21552192
},
2193+
"frontmatterRaw": "layout: cover
2194+
",
21562195
"importChain": [
21572196
{
21582197
"content": "",
@@ -2470,6 +2509,7 @@ layout: cover
24702509
24712510
$x+2$",
24722511
"frontmatter": {},
2512+
"frontmatterRaw": undefined,
24732513
"importChain": undefined,
24742514
"index": 8,
24752515
"level": 1,

0 commit comments

Comments
 (0)