diff --git a/src/writer.js b/src/writer.js index d8f8701..c81d229 100644 --- a/src/writer.js +++ b/src/writer.js @@ -81,6 +81,8 @@ async function loadMarkdownFilePromise(post) { // array of one or more strings outputValue = value.reduce((list, item) => `${list}\n - "${item}"`, ''); } + } else if (value instanceof luxon.DateTime) { + outputValue = encodeDate(value); } else { // single string value const escapedValue = (value || '').replace(/"/g, '\\"'); @@ -98,6 +100,16 @@ async function loadMarkdownFilePromise(post) { 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) { // collect image data from all posts into a single flattened array of payloads let skipCount = 0;