diff --git a/src/parser.js b/src/parser.js index ae8d152..3bd28e3 100644 --- a/src/parser.js +++ b/src/parser.js @@ -94,10 +94,12 @@ function getTags(post) { } function processCategoryTags(post, domain) { + if (!post.category) { + return []; + } return post.category .filter(c => c["$"].domain === domain) - .map(({ $: c }) => c.nicename) - .join(", "); + .map(({ $: c }) => c.nicename); } function collectAttachedImages(data) { diff --git a/src/writer.js b/src/writer.js index 5bff9c0..88d4e89 100644 --- a/src/writer.js +++ b/src/writer.js @@ -58,8 +58,10 @@ async function loadMarkdownFilePromise(post) { let output = '---\n'; Object.entries(post.frontmatter).forEach(pair => { const key = pair[0]; - const value = (pair[1] || '').replace(/"/g, '\\"'); - output += key + ': "' + value + '"\n'; + const value = Array.isArray(pair[1]) + ? (pair[1].length === 0 ? "" : "\n - \"" + pair[1].join("\"\n - \"") + "\"") + : '"' + (pair[1] || '').replace(/"/g, '\\"') +'"'; + output += key + ': ' + value + '\n'; }); output += '---\n\n' + post.content + '\n'; return output;