mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-07 13:44:55 +03:00
Add Universe products
This commit is contained in:
parent
a10c375d2f
commit
418cca87c0
|
@ -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])
|
||||
)
|
||||
|
|
48
website/pages/universe/project/[slug].tsx
Normal file
48
website/pages/universe/project/[slug].tsx
Normal file
|
@ -0,0 +1,48 @@
|
|||
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/components/layout'
|
||||
|
||||
type ParsedUrlQuery = {
|
||||
slug: string
|
||||
}
|
||||
|
||||
type PropsPage = {
|
||||
slug: ReadonlyArray<string>
|
||||
sectionTitle: string | null
|
||||
theme: string | null
|
||||
section: string
|
||||
isIndex: boolean
|
||||
}
|
||||
|
||||
export default Layout
|
||||
|
||||
export const getStaticPaths: GetStaticPaths<ParsedUrlQuery> = async () => {
|
||||
return {
|
||||
paths: universe.resources.flatMap((resource) => `/universe/project/${resource.id}`),
|
||||
fallback: false,
|
||||
}
|
||||
}
|
||||
|
||||
export const getStaticProps: GetStaticProps<PropsPage, ParsedUrlQuery> = 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,
|
||||
slug: args.params.slug.split('/'),
|
||||
isIndex: false,
|
||||
data: { ...resource, isProject: true },
|
||||
section: 'universe',
|
||||
sectionTitle: recordSections.universe.title,
|
||||
theme: recordSections.universe.theme,
|
||||
},
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user