Fix datetimes being incorrectly encoded in frontmatter as strings instead of YAML timestamps

This commit is contained in:
Ondřej Nývlt
2024-06-17 10:13:05 +02:00
committed by Will Boyd
parent 67bf6488c1
commit 8a25175c73
+12
View File
@@ -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;