diff --git a/website/meta/recordUniverse.tsx b/website/meta/recordUniverse.tsx index 3216b5672..588b0b9c0 100644 --- a/website/meta/recordUniverse.tsx +++ b/website/meta/recordUniverse.tsx @@ -3,3 +3,7 @@ import universe from './universe.json' export const recordUniverseCategories = Object.fromEntries( universe.categories.flatMap((category) => category.items.map((item) => [item.id, item])) ) + +export const recordUniverseResources = Object.fromEntries( + universe.resources.map((resource) => [resource.id, resource]) +) diff --git a/website/pages/models/[slug].tsx b/website/pages/models/[slug].tsx index 1698d6382..0e54fc2b1 100644 --- a/website/pages/models/[slug].tsx +++ b/website/pages/models/[slug].tsx @@ -2,8 +2,8 @@ import type { GetStaticPaths, GetStaticProps } from 'next' import models from '../../meta/languages.json' import recordSection from '../../meta/recordSections' import recordLanguages from '../../meta/recordLanguages' -import Layout from '../../src/components/layout' -import { PropsPageBase } from '../[...listPath]' +import Layout from '../../src/templates' +import { PropsPageBase } from '../[...listPathPage]' type PropsPageModel = PropsPageBase & { next: { title: string; slug: string } | null diff --git a/website/pages/universe/project/[slug].tsx b/website/pages/universe/project/[slug].tsx new file mode 100644 index 000000000..745247074 --- /dev/null +++ b/website/pages/universe/project/[slug].tsx @@ -0,0 +1,41 @@ +import { GetStaticPaths, GetStaticProps } from 'next' +import recordSections from '../../../meta/recordSections' +import { recordUniverseResources } from '../../../meta/recordUniverse' +import universe from '../../../meta/universe.json' +import Layout from '../../../src/templates' +import { PropsPageBase } from '../../[...listPathPage]' + +type ParsedUrlQuery = { + slug: string +} + +export default Layout + +export const getStaticPaths: GetStaticPaths = async () => { + return { + paths: universe.resources.flatMap((resource) => `/universe/project/${resource.id}`), + fallback: false, + } +} + +export const getStaticProps: GetStaticProps = async (args) => { + if (!args.params) { + return { notFound: true } + } + + const resource = recordUniverseResources[args.params.slug] + + return { + props: { + id: resource.id, + title: resource.title || resource.id, + teaser: resource.slogan || null, + slug: `/universe/project/${args.params.slug}`, + isIndex: false, + data: { ...resource, isProject: true }, + section: 'universe', + sectionTitle: recordSections.universe.title, + theme: recordSections.universe.theme, + }, + } +}