This commit is contained in:
2023-04-29 17:24:14 -07:00
parent a26588835b
commit cee1d41d6f
4 changed files with 4 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
import * as yaml from 'yaml';
export function process_frontmatter(document: string) {
export function process_frontmatter(document: string, parse = true) {
if (! document.startsWith('---\n')) {
return {
frontmatter: null,
@@ -12,7 +12,7 @@ export function process_frontmatter(document: string) {
const endIndex = document.slice(3).indexOf('\n---\n') + 3;
const frontmatterYaml = document.slice(3, endIndex);
const markdown = document.slice(endIndex + 4);
const frontmatter = yaml.parse(frontmatterYaml);
const frontmatter = parse ? frontmatterYaml : yaml.parse(frontmatterYaml);
return { frontmatter, markdown };
}