chore: update permalink configuration and content organization
Modified hugo.toml to use section in post front-matter for permalinks Updated layouts/_default/single.html to handle posts without categories Modified scripts/generate-content.js to organize content by category Deleted content/_index.md and added new category directories
This commit is contained in:
@@ -2,11 +2,11 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const DATA_DIR = path.join(__dirname, '..', 'data', 'wordpress');
|
||||
const CONTENT_DIR = path.join(__dirname, '..', 'content', 'posts');
|
||||
const CONTENT_DIR = path.join(__dirname, '..', 'content');
|
||||
|
||||
function generateContent() {
|
||||
const posts = JSON.parse(fs.readFileSync(path.join(DATA_DIR, 'posts.json'), 'utf8'));
|
||||
|
||||
|
||||
// Ensure content directory exists
|
||||
if (!fs.existsSync(CONTENT_DIR)) {
|
||||
fs.mkdirSync(CONTENT_DIR, { recursive: true });
|
||||
@@ -17,9 +17,14 @@ function generateContent() {
|
||||
const date = new Date(post.date);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
|
||||
const contentDir = path.join(CONTENT_DIR, `${year}-${month}-${slug}`);
|
||||
|
||||
|
||||
// Get the primary category (first category in the list)
|
||||
const primaryCategory = post._embedded?.['wp:term']?.[0]?.[0];
|
||||
const categorySlug = primaryCategory ? primaryCategory.slug : 'non-classe';
|
||||
|
||||
const contentDir = path.join(CONTENT_DIR, categorySlug, `${year}-${month}-${slug}`);
|
||||
// const contentDir = path.join(CONTENT_DIR, `${year}-${month}-${slug}`);
|
||||
|
||||
if (!fs.existsSync(contentDir)) {
|
||||
fs.mkdirSync(contentDir, { recursive: true });
|
||||
}
|
||||
@@ -45,7 +50,8 @@ function generateContent() {
|
||||
id: tag.id,
|
||||
name: tag.name,
|
||||
slug: tag.slug
|
||||
})) || []
|
||||
})) || [],
|
||||
// section: categorySlug
|
||||
};
|
||||
|
||||
const content = `---
|
||||
|
||||
Reference in New Issue
Block a user