mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-27 09:44:36 +03:00
Add Universe categories
This commit is contained in:
parent
7dac26df38
commit
cefbb3d203
5
website/meta/recordUniverse.tsx
Normal file
5
website/meta/recordUniverse.tsx
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import universe from './universe.json'
|
||||||
|
|
||||||
|
export const recordUniverseCategories = Object.fromEntries(
|
||||||
|
universe.categories.flatMap((category) => category.items.map((item) => [item.id, item]))
|
||||||
|
)
|
43
website/pages/universe/category/[slug].tsx
Normal file
43
website/pages/universe/category/[slug].tsx
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
import { GetStaticPaths, GetStaticProps } from 'next'
|
||||||
|
import recordSections from '../../../meta/recordSections'
|
||||||
|
import { recordUniverseCategories } 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<ParsedUrlQuery> = async () => {
|
||||||
|
return {
|
||||||
|
paths: universe.categories.flatMap((category) =>
|
||||||
|
category.items.map((item) => `/universe/category/${item.id}`)
|
||||||
|
),
|
||||||
|
fallback: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getStaticProps: GetStaticProps<PropsPageBase, ParsedUrlQuery> = async (args) => {
|
||||||
|
if (!args.params) {
|
||||||
|
return { notFound: true }
|
||||||
|
}
|
||||||
|
|
||||||
|
const item = recordUniverseCategories[args.params.slug]
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
id: item.id,
|
||||||
|
title: item.title,
|
||||||
|
teaser: item.description,
|
||||||
|
slug: `/universe/category/${args.params.slug}`,
|
||||||
|
isIndex: false,
|
||||||
|
data: { ...item, isCategory: true },
|
||||||
|
section: 'universe',
|
||||||
|
sectionTitle: recordSections.universe.title,
|
||||||
|
theme: recordSections.universe.theme,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user