From 71028a272b4629cbf94d09b1d2de9ccff208f7b7 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Mon, 3 Feb 2025 14:47:43 -0500 Subject: [PATCH] Fix date stuff in path building --- src/intake.js | 2 +- src/shared.js | 15 +++------------ src/writer.js | 2 +- 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/src/intake.js b/src/intake.js index 63763e2..ea2dfa8 100644 --- a/src/intake.js +++ b/src/intake.js @@ -158,7 +158,7 @@ function normalize(value, type, onError) { export function buildSamplePostPath(config) { const outputDir = path.sep; const type = ''; - const date = luxon.DateTime.now().toFormat('yyyy-LL-dd'); + const date = luxon.DateTime.now(); const slug = 'my-post'; return shared.buildPostPath(outputDir, type, date, slug, config); diff --git a/src/shared.js b/src/shared.js index 6557462..ecade32 100644 --- a/src/shared.js +++ b/src/shared.js @@ -1,30 +1,21 @@ -import * as luxon from 'luxon'; import path from 'path'; -import * as settings from './settings.js'; export function buildPostPath(outputDir, type, date, slug, config) { - let dt; - if (settings.custom_date_formatting) { - dt = luxon.DateTime.fromFormat(date, settings.custom_date_formatting); - } else { - dt = luxon.DateTime.fromISO(date); - } - // start with base output dir and post type const pathSegments = [outputDir, type]; if (config.dateFolders === 'year' || config.dateFolders === 'year-month') { - pathSegments.push(dt.toFormat('yyyy')); + pathSegments.push(date.toFormat('yyyy')); } if (config.dateFolders === 'year-month') { - pathSegments.push(dt.toFormat('LL')); + pathSegments.push(date.toFormat('LL')); } // create slug fragment, possibly date prefixed let slugFragment = slug; if (config.prefixDate) { - slugFragment = dt.toFormat('yyyy-LL-dd') + '-' + slugFragment; + slugFragment = date.toFormat('yyyy-LL-dd') + '-' + slugFragment; } // use slug fragment as folder or filename as specified diff --git a/src/writer.js b/src/writer.js index 239803b..1d82afa 100644 --- a/src/writer.js +++ b/src/writer.js @@ -179,7 +179,7 @@ async function loadImageFilePromise(imageUrl, config) { function buildPostPath(post, config) { const outputDir = config.output; const type = post.meta.type; - const date = post.frontmatter.date; + const date = post.meta.date; const slug = post.meta.slug; return shared.buildPostPath(outputDir, type, date, slug, config);