add category_slug, allow post_title to be null, fix linting

This commit is contained in:
Ron Rennick 2023-11-29 16:45:32 -04:00
parent 322f433455
commit d73d79d2ec
2 changed files with 3 additions and 2 deletions

View File

@ -32,8 +32,8 @@ export const generatePostFrontMatter = (
}, },
} ); } );
const content = frontMatter.content.split( '\n' ); const content = frontMatter.content.split( '\n' );
const headings = content.filter( ( line ) => '# ' == line.substring( 0, 2 ) ); const headings = content.filter( ( line ) => line.substring( 0, 2 ) === '# ' );
const title = ( headings[0]?.substring( 2 ) ?? '' ).trim(); const title = headings[0]?.substring( 2 ).trim();
frontMatter.data.post_title = frontMatter.data.post_title ?? title; frontMatter.data.post_title = frontMatter.data.post_title ?? title;
return Object.keys( frontMatter.data ) return Object.keys( frontMatter.data )

View File

@ -47,6 +47,7 @@ async function processDirectory(
const categoryFolder = path.basename( subDirectory ).split( '-' ); const categoryFolder = path.basename( subDirectory ).split( '-' );
const categoryTitle = categoryFolder const categoryTitle = categoryFolder
.map( ( slugPart ) => slugPart.charAt( 0 ).toUpperCase() + slugPart.slice( 1 ) ); .map( ( slugPart ) => slugPart.charAt( 0 ).toUpperCase() + slugPart.slice( 1 ) );
category.category_slug = categoryFolder;
category.category_title = categoryTitle.join( ' ' ); category.category_title = categoryTitle.join( ' ' );
} }