From 828230dedd5c548aef16fcef58dc48fdf4fcee04 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sun, 27 Dec 2020 14:05:48 -0500 Subject: [PATCH] Documentation and output for custom post types --- README.md | 10 +++++++++- src/parser.js | 2 +- src/translator.js | 2 +- src/writer.js | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a03556a..13eb9ef 100644 --- a/README.md +++ b/README.md @@ -153,7 +153,15 @@ Whether or not to download and save images attached to posts. Generally speaking - Type: `boolean` - Default: `true` -Whether or not to download and save images scraped from <img> tags in post body content. Images are saved into `/images`. The <img> tags are updated to point to where the images are saved. +Whether or not to download and save images scraped from `` tags in post body content. Images are saved into `/images`. The `` tags are updated to point to where the images are saved. + +### Include custom post types and pages? + +- Argument: `--include-other-types` +- Type: `boolean` +- Default: `false` + +Some WordPress sites make use of a `"page"` post type and/or custom post types. Set this to `true` to include these post types in the results. Posts will be organized into post type folders. ## Advanced Settings diff --git a/src/parser.js b/src/parser.js index 8afa320..3c2725b 100644 --- a/src/parser.js +++ b/src/parser.js @@ -35,7 +35,7 @@ function getItemTypes(data, config) { // effectively this will be 'post', 'page', and custom post types const types = data.rss.channel[0].item .map(item => item.post_type[0]) - .filter(type => !['attachment', 'revision', 'nav_menu_item'].includes(type)); + .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 diff --git a/src/translator.js b/src/translator.js index 194cd43..41c110b 100644 --- a/src/translator.js +++ b/src/translator.js @@ -66,7 +66,7 @@ function getPostContent(post, turndownService, config) { if (config.saveScrapedImages) { // writeImageFile() will save all content images to a relative /images - // folder so update references in post content to match + // folder so update references in post content to match content = content.replace(/(]*src=").*?([^/"]+\.(?:gif|jpe?g|png))("[^>]*>)/gi, '$1images/$2$3'); } diff --git a/src/writer.js b/src/writer.js index fad06a3..ed013ef 100644 --- a/src/writer.js +++ b/src/writer.js @@ -45,7 +45,7 @@ async function writeMarkdownFilesPromise(posts, config ) { // package up posts into payloads const payloads = posts.map((post, index) => ({ item: post, - name: post.meta.slug, + name: (config.includeOtherTypes ? post.meta.type + ' - ' : '') + post.meta.slug, destinationPath: getPostPath(post, config), delay: index * settings.markdown_file_write_delay }));