mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-06-05 15:09:59 +09:00
Refactor from wizard option to advanced setting
This commit is contained in:
+8
-4
@@ -18,10 +18,6 @@ exports.image_file_request_delay = 500;
|
||||
// overloaded.
|
||||
exports.markdown_file_write_delay = 25;
|
||||
|
||||
// Specify the timezone used for post dates. See available zone values and examples here:
|
||||
// https://moment.github.io/luxon/#/zones?id=specifying-a-zone.
|
||||
exports.custom_date_timezone = 'utc';
|
||||
|
||||
// Enable this to include time with post dates. For example, "2020-12-25" would become
|
||||
// "2020-12-25T11:20:35.000Z".
|
||||
exports.include_time_with_date = false;
|
||||
@@ -31,6 +27,14 @@ exports.include_time_with_date = false;
|
||||
// set, this takes precedence over include_time_with_date.
|
||||
exports.custom_date_formatting = '';
|
||||
|
||||
// Specify the timezone used for post dates. See available zone values and examples here:
|
||||
// https://moment.github.io/luxon/#/zones?id=specifying-a-zone.
|
||||
exports.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.
|
||||
exports.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.
|
||||
exports.strict_ssl = true;
|
||||
|
||||
@@ -74,12 +74,6 @@ const options = [
|
||||
type: 'boolean',
|
||||
description: 'Include custom post types and pages',
|
||||
default: false
|
||||
},
|
||||
{
|
||||
name: 'disable-strict-ssl',
|
||||
type: 'boolean',
|
||||
description: 'Strict SSL prevents image retrieval from self-signed servers',
|
||||
default: false
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
+5
-7
@@ -16,7 +16,7 @@ async function processPayloadsPromise(payloads, loadFunc) {
|
||||
const promises = payloads.map(payload => new Promise((resolve, reject) => {
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
const data = await loadFunc(payload.item, payload.strictSSL);
|
||||
const data = await loadFunc(payload.item);
|
||||
await writeFile(payload.destinationPath, data);
|
||||
console.log(chalk.green('[OK]') + ' ' + payload.name);
|
||||
resolve();
|
||||
@@ -41,7 +41,7 @@ async function writeFile(destinationPath, data) {
|
||||
await fs.promises.writeFile(destinationPath, data);
|
||||
}
|
||||
|
||||
async function writeMarkdownFilesPromise(posts, config ) {
|
||||
async function writeMarkdownFilesPromise(posts, config) {
|
||||
// package up posts into payloads
|
||||
let skipCount = 0;
|
||||
let delay = 0;
|
||||
@@ -55,7 +55,6 @@ async function writeMarkdownFilesPromise(posts, config ) {
|
||||
const payload = {
|
||||
item: post,
|
||||
name: (config.includeOtherTypes ? post.meta.type + ' - ' : '') + post.meta.slug,
|
||||
strictSSL: !config.disableStrictSsl,
|
||||
destinationPath,
|
||||
delay
|
||||
};
|
||||
@@ -73,7 +72,7 @@ async function writeMarkdownFilesPromise(posts, config ) {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadMarkdownFilePromise(post, strictSSL) {
|
||||
async function loadMarkdownFilePromise(post) {
|
||||
let output = '---\n';
|
||||
|
||||
Object.entries(post.frontmatter).forEach(([key, value]) => {
|
||||
@@ -118,7 +117,6 @@ async function writeImageFilesPromise(posts, config) {
|
||||
const payload = {
|
||||
item: imageUrl,
|
||||
name: filename,
|
||||
strictSSL: !config.disableStrictSsl,
|
||||
destinationPath,
|
||||
delay
|
||||
};
|
||||
@@ -137,7 +135,7 @@ async function writeImageFilesPromise(posts, config) {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadImageFilePromise(imageUrl, strictSSL) {
|
||||
async function loadImageFilePromise(imageUrl) {
|
||||
// only encode the URL if it doesn't already have encoded characters
|
||||
const url = (/%[\da-f]{2}/i).test(imageUrl) ? imageUrl : encodeURI(imageUrl);
|
||||
|
||||
@@ -149,7 +147,7 @@ async function loadImageFilePromise(imageUrl, strictSSL) {
|
||||
headers: {
|
||||
'User-Agent': 'wordpress-export-to-markdown'
|
||||
},
|
||||
strictSSL: strictSSL
|
||||
strictSSL: settings.strict_ssl
|
||||
});
|
||||
} catch (ex) {
|
||||
if (ex.name === 'StatusCodeError') {
|
||||
|
||||
Reference in New Issue
Block a user