File tree 1 file changed +4
-4
lines changed
src/containers/transform/frontmatters
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -2,23 +2,23 @@ import yaml from 'js-yaml';
2
2
3
3
const pattern = / ( ^ - { 3 } (?: \r \n | \r | \n ) ( [ \w \W ] * ?) - { 3 } (?: \r \n | \r | \n ) ) ? ( [ \w \W ] * ) * / ;
4
4
5
- export function frontmatter ( string ) {
5
+ export function frontmatter ( string : string ) {
6
6
const parsed = {
7
7
data : null ,
8
8
content : ''
9
9
} ;
10
10
11
11
const matches = string . match ( pattern ) ;
12
12
13
- if ( matches [ 2 ] !== undefined ) {
13
+ if ( matches && matches [ 2 ] !== undefined ) {
14
14
try {
15
15
parsed . data = yaml . load ( matches [ 2 ] ) || { } ;
16
16
} catch ( err ) {
17
17
console . error ( err ) ;
18
18
}
19
19
}
20
20
21
- if ( matches [ 3 ] !== undefined ) {
21
+ if ( matches && matches [ 3 ] !== undefined ) {
22
22
parsed . content = matches [ 3 ] ;
23
23
}
24
24
@@ -27,7 +27,7 @@ export function frontmatter(string) {
27
27
28
28
export const FRONTMATTER_DUMP_OPTS = {
29
29
flowLevel : 9 ,
30
- forceQuotes : false ,
30
+ forceQuotes : true ,
31
31
styles : {
32
32
'!!null' : 'camelcase'
33
33
}
You can’t perform that action at this time.
0 commit comments