mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-07-16 05:03:38 +09:00
Remove include-other-types option
This commit is contained in:
+7
-13
@@ -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) {
|
||||
|
||||
@@ -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'
|
||||
];
|
||||
|
||||
@@ -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
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
+3
-8
@@ -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'));
|
||||
|
||||
Reference in New Issue
Block a user