Skip to content

Commit ec71f9d

Browse files
fix stringify style
1 parent 7dbaae5 commit ec71f9d

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/front_matter.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ function split(str: string) {
3333
return { content: str };
3434
}
3535

36-
function parse(str: string, options) {
36+
interface ParseOptions {
37+
defaultTimeZone?: string;
38+
}
39+
40+
function parse(str: string, options: ParseOptions = {}) {
3741
if (typeof str !== 'string') throw new TypeError('str is required!');
3842

3943
const splitData = split(str);
@@ -55,11 +59,7 @@ function parse(str: string, options) {
5559
return data;
5660
}
5761

58-
interface ParseOptions {
59-
defaultTimeZone?: string;
60-
}
61-
62-
function parseYAML(str, options: ParseOptions = {}) {
62+
function parseYAML(str, options: ParseOptions) {
6363
const result = ymlParse(escapeYAML(str), {
6464
customTags: [timestampFactory(options.defaultTimeZone)]
6565
});
@@ -113,7 +113,10 @@ function stringify(obj, options: StringifyOptions = {}) {
113113
if (mode === 'json') {
114114
result += stringifyJSON(obj);
115115
} else {
116-
result += stringifyYAML(obj, options);
116+
result += stringifyYAML(obj, {
117+
defaultStringType: 'PLAIN',
118+
singleQuote: true
119+
});
117120
}
118121

119122
result += `${separator}\n${content}`;

0 commit comments

Comments
 (0)