From 2c31e38ca47ead6c8f550a4da9f067b83b94630f Mon Sep 17 00:00:00 2001 From: Emmanuel Gautier Date: Wed, 13 Sep 2023 23:04:54 +0200 Subject: [PATCH] feat: add tags template path --- packages/config/src/config.mts | 4 ++++ packages/config/src/consts.mts | 2 ++ packages/explorer/src/core/content/compute.mts | 12 ++---------- packages/explorer/src/core/content/types/index.mts | 4 +++- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/config/src/config.mts b/packages/config/src/config.mts index 70bd0a77..7351e95b 100644 --- a/packages/config/src/config.mts +++ b/packages/config/src/config.mts @@ -74,6 +74,10 @@ const defaultPages: GalactiksConfig['pages'] = { organizations: { path: '/organizations/{/identifier}', }, + + tags: { + path: '/tags/{/identifier}', + }, }; let _config: GalactiksConfig; diff --git a/packages/config/src/consts.mts b/packages/config/src/consts.mts index 70fab0c2..40ad7a5e 100644 --- a/packages/config/src/consts.mts +++ b/packages/config/src/consts.mts @@ -3,12 +3,14 @@ export enum pageDocumentTypes { Organization = 'organizations', Page = 'pages', Person = 'people', + Tag = 'tags', } export enum documentTypes { Article = pageDocumentTypes.Article, Organization = pageDocumentTypes.Organization, Page = pageDocumentTypes.Page, Person = pageDocumentTypes.Person, + Tag = pageDocumentTypes.Tag, WebPageElement = 'webPageElements', Website = 'websites', } diff --git a/packages/explorer/src/core/content/compute.mts b/packages/explorer/src/core/content/compute.mts index b5c151e7..bef2b261 100644 --- a/packages/explorer/src/core/content/compute.mts +++ b/packages/explorer/src/core/content/compute.mts @@ -42,7 +42,7 @@ function createPage( identifier: string, document: Partial ) { - const id = slugify(identifier); + const id = slugify(identifier, { lower: true, trim: true }); return { _id: id, @@ -116,14 +116,6 @@ const computeRemainingListingPages = async ( // Create all keywords pages not existing yet if (Array.isArray(keywords)) { - if ( - acc.some( - (_a) => _a.identifier === 'tags' && isInLanguage(_a, inLanguage) - ) === false - ) { - acc = acc.concat(createListingPage('tags', templateDocument)); - } - acc = acc.concat( keywords .filter( @@ -135,7 +127,7 @@ const computeRemainingListingPages = async ( .map((_k) => createListingPage(_k, { ...templateDocument, - isPartOf: 'tags', + type: 'Tag', }) ) ); diff --git a/packages/explorer/src/core/content/types/index.mts b/packages/explorer/src/core/content/types/index.mts index ad318e9e..fee07f39 100644 --- a/packages/explorer/src/core/content/types/index.mts +++ b/packages/explorer/src/core/content/types/index.mts @@ -20,7 +20,9 @@ export type { WebPageElement as ContentlayerWebPageElement, } from './contentlayer.mjs'; export type * from './_schemas.mjs'; +type ContentlayerTagPage = Omit & { type: 'Tag' }; export type ContentlayerWebPageDocument = | ContentlayerArticle | ContentlayerPage - | ContentlayerPerson; + | ContentlayerPerson + | ContentlayerTagPage;