mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-07-20 07:04:14 +09:00
Filter out trashed and draft posts
This commit is contained in:
@@ -37,6 +37,7 @@ function collectPosts(data, config) {
|
|||||||
const turndownService = translator.initTurndownService();
|
const turndownService = translator.initTurndownService();
|
||||||
|
|
||||||
const posts = getItemsOfType(data, 'post')
|
const posts = getItemsOfType(data, 'post')
|
||||||
|
.filter(post => post.status[0] !== 'trash' && post.status[0] !== 'draft')
|
||||||
.map(post => ({
|
.map(post => ({
|
||||||
// meta data isn't written to file, but is used to help with other things
|
// meta data isn't written to file, but is used to help with other things
|
||||||
meta: {
|
meta: {
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ async function loadMarkdownFilePromise(post) {
|
|||||||
let output = '---\n';
|
let output = '---\n';
|
||||||
Object.entries(post.frontmatter).forEach(pair => {
|
Object.entries(post.frontmatter).forEach(pair => {
|
||||||
const key = pair[0];
|
const key = pair[0];
|
||||||
const value = pair[1].replace(/"/g, '\\"');
|
const value = (pair[1] || '').replace(/"/g, '\\"');
|
||||||
output += key + ': "' + value + '"\n';
|
output += key + ': "' + value + '"\n';
|
||||||
});
|
});
|
||||||
output += '---\n\n' + post.content + '\n';
|
output += '---\n\n' + post.content + '\n';
|
||||||
|
|||||||
Reference in New Issue
Block a user