From a645b2bfdccb9f8a36b3fcb6a033ae2490664075 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sat, 8 Feb 2025 12:36:08 -0500 Subject: [PATCH] Output frontmatter id as integer --- src/frontmatter.js | 6 +++--- src/parser.js | 2 +- src/writer.js | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/frontmatter.js b/src/frontmatter.js index 821104c..d513079 100644 --- a/src/frontmatter.js +++ b/src/frontmatter.js @@ -34,9 +34,9 @@ export function excerpt(post) { return post.data.encoded[1].replace(/[\r\n]+/gm, ' '); } -// get ID +// get ID, as an integer export function id(post) { - return post.data.post_id[0]; + return parseInt(post.id); } // get slug, previously decoded and set on post @@ -65,5 +65,5 @@ export function title(post) { // get type, often this will always be "post" // but can also be "page" or other custom types export function type(post) { - return post.data.post_type[0]; + return post.type; } diff --git a/src/parser.js b/src/parser.js index f8c06b6..212774f 100644 --- a/src/parser.js +++ b/src/parser.js @@ -74,7 +74,7 @@ function collectPosts(channelData, postTypes) { function buildPost(data, turndownService) { return { - // full raw post data, used by some frontmatter getters + // full raw post data data, // contents of the post in markdown diff --git a/src/writer.js b/src/writer.js index a201fcf..f289591 100644 --- a/src/writer.js +++ b/src/writer.js @@ -83,6 +83,9 @@ async function loadMarkdownFilePromise(post) { // array of one or more strings outputValue = value.reduce((list, item) => `${list}\n - "${item}"`, ''); } + } else if (Number.isInteger(value)) { + // output unquoted + outputValue = value.toString(); } else if (value instanceof luxon.DateTime) { if (shared.config.customDateFormatting) { outputValue = value.toFormat(shared.config.customDateFormatting);