Skip to content

Commit

Permalink
fix: yaml frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
Myllaume committed Dec 2, 2024
1 parent ec7c134 commit dec9343
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/utils/yamlfrontmatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const regex = /^(-{3}(?:\n|\r)([\w\W]+?)(?:\n|\r)[-|\.]{3})?([\w\W]*)*/;
* Read head of markdown files as YAML content
* Get result as JSON
* @param {string} fileContent
* @param {object} options https://eemeli.org/yaml/#options
* @param {import('yaml').ParseOptions & import('yaml').SchemaOptions} options
* @returns {{head: unknown, content: string}} JSON
*/

Expand All @@ -19,7 +19,7 @@ function read(fileContent, options = {}) {

let ymlResult = {};

if (!!fileContent) {
if (fileContent && withoutDash) {
ymlResult = yml.parse(withoutDash, options);
}

Expand Down
8 changes: 8 additions & 0 deletions core/utils/yamlfrontmatter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ Paul Otlet est la tête pensante du Mundaneum`,
},
description: 'Empty',
},
{
input: 'No Yaml Front Matter',
expected: {
content: 'No Yaml Front Matter',
head: {},
},
description: 'No head',
},
];

describe('YAML Front Matter parser', function () {
Expand Down

0 comments on commit dec9343

Please sign in to comment.