All pages are displayed but only published must
This commit is contained in:
@@ -19,8 +19,8 @@ function generateContent() {
|
||||
fs.mkdirSync(PAGES_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
// Process posts
|
||||
posts.forEach(post => {
|
||||
// Process posts - only include published posts
|
||||
posts.filter(post => post.status === 'publish').forEach(post => {
|
||||
const slug = post.slug;
|
||||
const date = new Date(post.date);
|
||||
const year = date.getFullYear();
|
||||
@@ -40,7 +40,7 @@ function generateContent() {
|
||||
const frontmatter = {
|
||||
title: he.decode(post.title.rendered),
|
||||
date: post.date,
|
||||
draft: post.status !== 'publish',
|
||||
draft: false,
|
||||
slug: slug,
|
||||
wordpress_id: post.id,
|
||||
excerpt: he.decode(post.excerpt.rendered.replace(/<[^>]*>/g, '')),
|
||||
@@ -80,8 +80,8 @@ ${contentHtml.trim()}`;
|
||||
fs.writeFileSync(path.join(contentDir, 'index.md'), content);
|
||||
});
|
||||
|
||||
// Process pages
|
||||
pages.forEach(page => {
|
||||
// Process pages - only include published pages
|
||||
pages.filter(page => page.status === 'publish').forEach(page => {
|
||||
const slug = page.slug;
|
||||
|
||||
const contentDir = path.join(PAGES_DIR, slug);
|
||||
@@ -98,7 +98,7 @@ ${contentHtml.trim()}`;
|
||||
wordpress_id: page.id,
|
||||
date: page.date,
|
||||
modified: page.modified,
|
||||
draft: page.status !== 'publish',
|
||||
draft: false,
|
||||
aliases: [`/${slug}/`]
|
||||
};
|
||||
|
||||
@@ -131,8 +131,10 @@ ${contentHtml.trim()}`;
|
||||
fs.writeFileSync(path.join(contentDir, 'index.md'), content);
|
||||
});
|
||||
|
||||
console.log(`✅ Generated ${posts.length} content files`);
|
||||
console.log(`✅ Generated ${pages.length} page files`);
|
||||
const publishedPosts = posts.filter(post => post.status === 'publish');
|
||||
const publishedPages = pages.filter(page => page.status === 'publish');
|
||||
console.log(`✅ Generated ${publishedPosts.length} content files`);
|
||||
console.log(`✅ Generated ${publishedPages.length} page files`);
|
||||
}
|
||||
|
||||
generateContent();
|
||||
Reference in New Issue
Block a user