mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-06-05 15:09:59 +09:00
Show slug fallback when writing
This commit is contained in:
+5
-1
@@ -7,6 +7,10 @@ export function camelCase(str) {
|
||||
return str.replace(/-(.)/g, (match) => match[1].toUpperCase());
|
||||
}
|
||||
|
||||
export function getSlugWithFallback(post) {
|
||||
return post.slug ? post.slug : 'id-' + post.id;
|
||||
}
|
||||
|
||||
export function buildPostPath(post, overrideConfig) {
|
||||
const pathConfig = overrideConfig ?? config;
|
||||
|
||||
@@ -35,7 +39,7 @@ export function buildPostPath(post, overrideConfig) {
|
||||
}
|
||||
|
||||
// get slug with fallback
|
||||
let slug = post.slug ? post.slug : 'id-' + post.id;
|
||||
let slug = getSlugWithFallback(post);
|
||||
|
||||
// prepend date to slug as appropriate
|
||||
if (pathConfig.prefixDate && post.date) {
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ async function writeMarkdownFilesPromise(posts) {
|
||||
const payload = {
|
||||
item: post,
|
||||
type: post.type,
|
||||
name: post.slug,
|
||||
name: shared.getSlugWithFallback(post),
|
||||
destinationPath,
|
||||
delay
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user