mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-07-19 22:54:11 +09:00
Output frontmatter id as integer
This commit is contained in:
+3
-3
@@ -34,9 +34,9 @@ export function excerpt(post) {
|
|||||||
return post.data.encoded[1].replace(/[\r\n]+/gm, ' ');
|
return post.data.encoded[1].replace(/[\r\n]+/gm, ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
// get ID
|
// get ID, as an integer
|
||||||
export function id(post) {
|
export function id(post) {
|
||||||
return post.data.post_id[0];
|
return parseInt(post.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get slug, previously decoded and set on post
|
// get slug, previously decoded and set on post
|
||||||
@@ -65,5 +65,5 @@ export function title(post) {
|
|||||||
// get type, often this will always be "post"
|
// get type, often this will always be "post"
|
||||||
// but can also be "page" or other custom types
|
// but can also be "page" or other custom types
|
||||||
export function type(post) {
|
export function type(post) {
|
||||||
return post.data.post_type[0];
|
return post.type;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -74,7 +74,7 @@ function collectPosts(channelData, postTypes) {
|
|||||||
|
|
||||||
function buildPost(data, turndownService) {
|
function buildPost(data, turndownService) {
|
||||||
return {
|
return {
|
||||||
// full raw post data, used by some frontmatter getters
|
// full raw post data
|
||||||
data,
|
data,
|
||||||
|
|
||||||
// contents of the post in markdown
|
// contents of the post in markdown
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ async function loadMarkdownFilePromise(post) {
|
|||||||
// array of one or more strings
|
// array of one or more strings
|
||||||
outputValue = value.reduce((list, item) => `${list}\n - "${item}"`, '');
|
outputValue = value.reduce((list, item) => `${list}\n - "${item}"`, '');
|
||||||
}
|
}
|
||||||
|
} else if (Number.isInteger(value)) {
|
||||||
|
// output unquoted
|
||||||
|
outputValue = value.toString();
|
||||||
} else if (value instanceof luxon.DateTime) {
|
} else if (value instanceof luxon.DateTime) {
|
||||||
if (shared.config.customDateFormatting) {
|
if (shared.config.customDateFormatting) {
|
||||||
outputValue = value.toFormat(shared.config.customDateFormatting);
|
outputValue = value.toFormat(shared.config.customDateFormatting);
|
||||||
|
|||||||
Reference in New Issue
Block a user