Skip to content

Commit

Permalink
Merge pull request #53 from thegalactiks/tags-path
Browse files Browse the repository at this point in the history
feat: add tags template path
  • Loading branch information
emmanuelgautier authored Sep 13, 2023
2 parents d222d93 + 2c31e38 commit f09774b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 4 additions & 0 deletions packages/config/src/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ const defaultPages: GalactiksConfig['pages'] = {
organizations: {
path: '/organizations/{/identifier}',
},

tags: {
path: '/tags/{/identifier}',
},
};

let _config: GalactiksConfig;
Expand Down
2 changes: 2 additions & 0 deletions packages/config/src/consts.mts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
12 changes: 2 additions & 10 deletions packages/explorer/src/core/content/compute.mts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function createPage<T>(
identifier: string,
document: Partial<ContentlayerWebPageDocument>
) {
const id = slugify(identifier);
const id = slugify(identifier, { lower: true, trim: true });

return {
_id: id,
Expand Down Expand Up @@ -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(
Expand All @@ -135,7 +127,7 @@ const computeRemainingListingPages = async (
.map((_k) =>
createListingPage(_k, {
...templateDocument,
isPartOf: 'tags',
type: 'Tag',
})
)
);
Expand Down
4 changes: 3 additions & 1 deletion packages/explorer/src/core/content/types/index.mts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ export type {
WebPageElement as ContentlayerWebPageElement,
} from './contentlayer.mjs';
export type * from './_schemas.mjs';
type ContentlayerTagPage = Omit<ContentlayerPage, 'type'> & { type: 'Tag' };
export type ContentlayerWebPageDocument =
| ContentlayerArticle
| ContentlayerPage
| ContentlayerPerson;
| ContentlayerPerson
| ContentlayerTagPage;

0 comments on commit f09774b

Please sign in to comment.