mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-07-19 14:43:58 +09:00
Fix date stuff in path building
This commit is contained in:
+1
-1
@@ -158,7 +158,7 @@ function normalize(value, type, onError) {
|
|||||||
export function buildSamplePostPath(config) {
|
export function buildSamplePostPath(config) {
|
||||||
const outputDir = path.sep;
|
const outputDir = path.sep;
|
||||||
const type = '';
|
const type = '';
|
||||||
const date = luxon.DateTime.now().toFormat('yyyy-LL-dd');
|
const date = luxon.DateTime.now();
|
||||||
const slug = 'my-post';
|
const slug = 'my-post';
|
||||||
|
|
||||||
return shared.buildPostPath(outputDir, type, date, slug, config);
|
return shared.buildPostPath(outputDir, type, date, slug, config);
|
||||||
|
|||||||
+3
-12
@@ -1,30 +1,21 @@
|
|||||||
import * as luxon from 'luxon';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import * as settings from './settings.js';
|
|
||||||
|
|
||||||
export function buildPostPath(outputDir, type, date, slug, config) {
|
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
|
// start with base output dir and post type
|
||||||
const pathSegments = [outputDir, type];
|
const pathSegments = [outputDir, type];
|
||||||
|
|
||||||
if (config.dateFolders === 'year' || config.dateFolders === 'year-month') {
|
if (config.dateFolders === 'year' || config.dateFolders === 'year-month') {
|
||||||
pathSegments.push(dt.toFormat('yyyy'));
|
pathSegments.push(date.toFormat('yyyy'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.dateFolders === 'year-month') {
|
if (config.dateFolders === 'year-month') {
|
||||||
pathSegments.push(dt.toFormat('LL'));
|
pathSegments.push(date.toFormat('LL'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// create slug fragment, possibly date prefixed
|
// create slug fragment, possibly date prefixed
|
||||||
let slugFragment = slug;
|
let slugFragment = slug;
|
||||||
if (config.prefixDate) {
|
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
|
// use slug fragment as folder or filename as specified
|
||||||
|
|||||||
+1
-1
@@ -179,7 +179,7 @@ async function loadImageFilePromise(imageUrl, config) {
|
|||||||
function buildPostPath(post, config) {
|
function buildPostPath(post, config) {
|
||||||
const outputDir = config.output;
|
const outputDir = config.output;
|
||||||
const type = post.meta.type;
|
const type = post.meta.type;
|
||||||
const date = post.frontmatter.date;
|
const date = post.meta.date;
|
||||||
const slug = post.meta.slug;
|
const slug = post.meta.slug;
|
||||||
|
|
||||||
return shared.buildPostPath(outputDir, type, date, slug, config);
|
return shared.buildPostPath(outputDir, type, date, slug, config);
|
||||||
|
|||||||
Reference in New Issue
Block a user