From d73d79d2ec6d58846cb7a8fb5f188c149d810b4f Mon Sep 17 00:00:00 2001 From: Ron Rennick Date: Wed, 29 Nov 2023 16:45:32 -0400 Subject: [PATCH] add category_slug, allow post_title to be null, fix linting --- tools/monorepo-utils/src/md-docs/lib/generate-frontmatter.ts | 4 ++-- tools/monorepo-utils/src/md-docs/lib/generate-manifest.ts | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/monorepo-utils/src/md-docs/lib/generate-frontmatter.ts b/tools/monorepo-utils/src/md-docs/lib/generate-frontmatter.ts index 76bb7f81a48..1f0acb2fa9e 100644 --- a/tools/monorepo-utils/src/md-docs/lib/generate-frontmatter.ts +++ b/tools/monorepo-utils/src/md-docs/lib/generate-frontmatter.ts @@ -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 ) diff --git a/tools/monorepo-utils/src/md-docs/lib/generate-manifest.ts b/tools/monorepo-utils/src/md-docs/lib/generate-manifest.ts index 9c8a330d5df..4c597109e17 100644 --- a/tools/monorepo-utils/src/md-docs/lib/generate-manifest.ts +++ b/tools/monorepo-utils/src/md-docs/lib/generate-manifest.ts @@ -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( ' ' ); }