From da4af6608a7949dc8562934b43523bd3f54baa27 Mon Sep 17 00:00:00 2001 From: Will Boyd Date: Sun, 2 Feb 2025 15:32:37 -0500 Subject: [PATCH] Hardcode filter-categories and filter-post-types --- src/frontmatter.js | 6 +++--- src/parser.js | 11 +++++++++-- src/settings.js | 22 +++++++++++----------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/frontmatter.js b/src/frontmatter.js index 6b62c3b..f2c74e1 100644 --- a/src/frontmatter.js +++ b/src/frontmatter.js @@ -7,8 +7,8 @@ export function author(post) { return post.data.creator[0]; } -// get array of decoded category names, filtered as specified in settings -export function categories(post, config) { +// get array of decoded category names, excluding 'uncategorized' +export function categories(post) { if (!post.data.category) { return []; } @@ -17,7 +17,7 @@ export function categories(post, config) { .filter(category => category.$.domain === 'category') .map(({ $: attributes }) => decodeURIComponent(attributes.nicename)); - return categories.filter((category) => !config.filterCategories.includes(category)); + return categories.filter((category) => category !== 'uncategorized'); } // get cover image filename, previously decoded and set on post.meta diff --git a/src/parser.js b/src/parser.js index 50bec3e..0537bf2 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1,7 +1,6 @@ import fs from 'fs'; import xml2js from 'xml2js'; import * as frontmatter from './frontmatter.js'; -import * as settings from './settings.js'; import * as shared from './shared.js'; import * as translator from './translator.js'; @@ -35,7 +34,15 @@ 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)); + .filter(type => ![ + 'attachment', + 'revision', + 'nav_menu_item', + 'custom_css', + 'customize_changeset', + 'wp_global_styles', + 'wp_navigation' + ].includes(type)); return [...new Set(types)]; // remove duplicates } diff --git a/src/settings.js b/src/settings.js index a072e1e..97f5e9e 100644 --- a/src/settings.js +++ b/src/settings.js @@ -33,19 +33,19 @@ export const custom_date_timezone = 'utc'; // Categories to be excluded from post frontmatter. This does not filter out posts themselves, // just the categories listed in their frontmatter. -export const filter_categories = ['uncategorized']; +// 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; +// 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' -]; +// export const filter_post_types = [ +// 'attachment', +// 'revision', +// 'nav_menu_item', +// 'custom_css', +// 'customize_changeset', +// 'wp_global_styles', +// 'wp_navigation' +// ];