From 2add3804061f85365458203f49f135a94f38d90e Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Mon, 20 Jan 2025 16:09:27 -0500 Subject: [PATCH] Remove include-other-types option --- src/parser.js | 20 +++++++------------- src/settings.js | 11 +++++++++++ src/wizard.js | 6 ------ src/writer.js | 11 +++-------- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/parser.js b/src/parser.js index 4083dd0..a4cbadc 100644 --- a/src/parser.js +++ b/src/parser.js @@ -14,7 +14,7 @@ export async function parseFilePromise(config) { }); const channelData = allData.rss.channel[0].item; - const postTypes = getPostTypes(channelData, config); + const postTypes = getPostTypes(channelData); const posts = collectPosts(channelData, postTypes, config); const images = []; @@ -31,18 +31,12 @@ export async function parseFilePromise(config) { return posts; } -function getPostTypes(channelData, config) { - if (config.includeOtherTypes) { - // search export file for all post types minus some default types we don't want - // effectively this will be 'post', 'page', and custom post types - const types = channelData - .map(item => item.post_type[0]) - .filter(type => !['attachment', 'revision', 'nav_menu_item', 'custom_css', 'customize_changeset'].includes(type)); - return [...new Set(types)]; // remove duplicates - } else { - // just plain old vanilla "post" posts - return ['post']; - } +function getPostTypes(channelData) { + // search export file for all post types minus some specific types we don't want + const types = channelData + .map(item => item.post_type[0]) + .filter(type => !settings.filter_post_types.includes(type)); + return [...new Set(types)]; // remove duplicates } function getItemsOfType(channelData, type) { diff --git a/src/settings.js b/src/settings.js index 111ed0e..58e67b3 100644 --- a/src/settings.js +++ b/src/settings.js @@ -38,3 +38,14 @@ export const filter_categories = ['uncategorized']; // Strict SSL is enabled as the safe default when downloading images, but will not work with // self-signed servers. You can disable it if you're getting a "self-signed certificate" error. export const strict_ssl = true; + +// Post types to exclude from output. +export const filter_post_types = [ + 'attachment', + 'revision', + 'nav_menu_item', + 'custom_css', + 'customize_changeset', + 'wp_global_styles', + 'wp_navigation' +]; diff --git a/src/wizard.js b/src/wizard.js index e5d4b1a..e625a47 100644 --- a/src/wizard.js +++ b/src/wizard.js @@ -60,12 +60,6 @@ const options = [ type: 'boolean', description: 'Save images scraped from post body content', default: true - }, - { - name: 'include-other-types', - type: 'boolean', - description: 'Include custom post types and pages', - default: false } ]; diff --git a/src/writer.js b/src/writer.js index 510eaf3..7df7520 100644 --- a/src/writer.js +++ b/src/writer.js @@ -55,7 +55,7 @@ async function writeMarkdownFilesPromise(posts, config) { } else { const payload = { item: post, - name: (config.includeOtherTypes ? post.meta.type + ' - ' : '') + post.meta.slug, + name: post.meta.type + ' - ' + post.meta.slug, destinationPath, delay }; @@ -179,13 +179,8 @@ function getPostPath(post, config) { dt = luxon.DateTime.fromISO(post.frontmatter.date); } - // start with base output dir - const pathSegments = [config.output]; - - // create segment for post type if we're dealing with more than just "post" - if (config.includeOtherTypes) { - pathSegments.push(post.meta.type); - } + // start with base output dir and post type + const pathSegments = [config.output, post.meta.type]; if (config.yearFolders) { pathSegments.push(dt.toFormat('yyyy'));