Skip to content

Commit a926191

Browse files
committed
Avoiding the import of draft posts. It removes erros from data that is not part of the publish posts.
1 parent 631d372 commit a926191

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

importer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ const path = require('path')
1212
const importPosts = async (file) => {
1313
const feed = await parseFeed(file)
1414

15+
const isPost = item => item['wp:post_type']['#'] === 'post'
16+
const isPublished = item => item['wp:status']['#'] === 'publish'
17+
1518
// Filter for only blog posts
16-
var items = feed.items.filter((item, index) => item['wp:post_type']['#'] === 'post')
19+
var items = feed.items.filter(isPost).filter(isPublished)
1720

1821
// Map to new object type
1922
items = items.map(item => {
20-
if (item['wp:post_type']['#'] !== 'post') {
23+
if (!isPost(item)) {
2124
return
2225
}
2326

0 commit comments

Comments
 (0)