Skip to content

Commit 1de7b11

Browse files
committed
Force quotes in frontmatter
1 parent c6a8080 commit 1de7b11

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/containers/transform/frontmatters/frontmatter.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ import yaml from 'js-yaml';
22

33
const pattern = /(^-{3}(?:\r\n|\r|\n)([\w\W]*?)-{3}(?:\r\n|\r|\n))?([\w\W]*)*/;
44

5-
export function frontmatter(string) {
5+
export function frontmatter(string: string) {
66
const parsed = {
77
data: null,
88
content: ''
99
};
1010

1111
const matches = string.match(pattern);
1212

13-
if (matches[2] !== undefined) {
13+
if (matches && matches[2] !== undefined) {
1414
try {
1515
parsed.data = yaml.load(matches[2]) || {};
1616
} catch (err) {
1717
console.error(err);
1818
}
1919
}
2020

21-
if (matches[3] !== undefined) {
21+
if (matches && matches[3] !== undefined) {
2222
parsed.content = matches[3];
2323
}
2424

@@ -27,7 +27,7 @@ export function frontmatter(string) {
2727

2828
export const FRONTMATTER_DUMP_OPTS = {
2929
flowLevel: 9,
30-
forceQuotes: false,
30+
forceQuotes: true,
3131
styles: {
3232
'!!null' : 'camelcase'
3333
}

0 commit comments

Comments
 (0)