Output frontmatter id as integer

This commit is contained in:
Will Boyd
2025-02-08 12:36:08 -05:00
parent 1524e052bb
commit a645b2bfdc
3 changed files with 7 additions and 4 deletions
+3 -3
View File
@@ -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;
}
+1 -1
View File
@@ -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
+3
View File
@@ -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);