mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-07-11 18:56:14 +09:00
Fix datetimes being incorrectly encoded in frontmatter as strings instead of YAML timestamps
This commit is contained in:
@@ -81,6 +81,8 @@ 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 (value instanceof luxon.DateTime) {
|
||||||
|
outputValue = encodeDate(value);
|
||||||
} else {
|
} else {
|
||||||
// single string value
|
// single string value
|
||||||
const escapedValue = (value || '').replace(/"/g, '\\"');
|
const escapedValue = (value || '').replace(/"/g, '\\"');
|
||||||
@@ -98,6 +100,16 @@ async function loadMarkdownFilePromise(post) {
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function encodeDate(dateTime) {
|
||||||
|
if (settings.custom_date_formatting) {
|
||||||
|
return dateTime.toFormat(settings.custom_date_formatting);
|
||||||
|
} else if (settings.include_time_with_date) {
|
||||||
|
return dateTime.toISO();
|
||||||
|
} else {
|
||||||
|
return dateTime.toISODate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function writeImageFilesPromise(posts, config) {
|
async function writeImageFilesPromise(posts, config) {
|
||||||
// collect image data from all posts into a single flattened array of payloads
|
// collect image data from all posts into a single flattened array of payloads
|
||||||
let skipCount = 0;
|
let skipCount = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user