add category_slug, allow post_title to be null, fix linting
This commit is contained in:
parent
322f433455
commit
d73d79d2ec
|
@ -32,8 +32,8 @@ export const generatePostFrontMatter = (
|
|||
},
|
||||
} );
|
||||
const content = frontMatter.content.split( '\n' );
|
||||
const headings = content.filter( ( line ) => '# ' == line.substring( 0, 2 ) );
|
||||
const title = ( headings[0]?.substring( 2 ) ?? '' ).trim();
|
||||
const headings = content.filter( ( line ) => line.substring( 0, 2 ) === '# ' );
|
||||
const title = headings[0]?.substring( 2 ).trim();
|
||||
|
||||
frontMatter.data.post_title = frontMatter.data.post_title ?? title;
|
||||
return Object.keys( frontMatter.data )
|
||||
|
|
|
@ -47,6 +47,7 @@ async function processDirectory(
|
|||
const categoryFolder = path.basename( subDirectory ).split( '-' );
|
||||
const categoryTitle = categoryFolder
|
||||
.map( ( slugPart ) => slugPart.charAt( 0 ).toUpperCase() + slugPart.slice( 1 ) );
|
||||
category.category_slug = categoryFolder;
|
||||
category.category_title = categoryTitle.join( ' ' );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue