diff --git a/src/pages/honkai3rd/stigmata/[stigmataId].tsx b/src/pages/honkai3rd/stigmata/[stigmataId].tsx index fba2e162..d8ca2572 100644 --- a/src/pages/honkai3rd/stigmata/[stigmataId].tsx +++ b/src/pages/honkai3rd/stigmata/[stigmataId].tsx @@ -2,6 +2,7 @@ import { Box, Heading, Text, Paragraph, Card, Flex } from '@theme-ui/components' import { NextPageContext } from 'next' import Image from 'next/image' import React from 'react' +import PageLink from '../../../components/atoms/PageLink' import StigmataCard from '../../../components/molecules/StigmataCard' import Breadcrumb from '../../../components/organisms/Breadcrumb' import Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator' @@ -12,116 +13,213 @@ import { getStigmataById, getStigmataListBySetId, getStigmataSetBySetId, + listStigmataSet, } from '../../../server/data/honkai3rd/stigmata' -interface StigmataShowPageProps { +interface SingleStigmataPageProps { + type: 'single' stigmataData: StigmataData stigmataSetList: StigmataData[] stigmataSet?: StigmataSet } -const StigmataListPage = ({ - stigmataData, - stigmataSetList = [], - stigmataSet, -}: StigmataShowPageProps) => { +interface StigmataSetProps { + type: 'set' + stigmataSet: StigmataSet + stigmataSetList: StigmataData[] +} + +type StigmataShowPageProps = SingleStigmataPageProps | StigmataSetProps + +const StigmataListPage = (props: StigmataShowPageProps) => { + if (props.type === 'single') { + const { stigmataData, stigmataSet, stigmataSetList } = props + + return ( + + + + + + {stigmataData.name} + + + {stigmataData.name} + + + + + {capitalize(stigmataData.type)} + + + {'⭐'.repeat(stigmataData.rarity)} + + + HP : {stigmataData.hp} / ATK : {stigmataData.atk} / DEF :{' '} + {stigmataData.def} / CRT : {stigmataData.crt} + + + + + + Skill - {stigmataData.skill.name} + + {stigmataData.skill.description} + + + {stigmataSet != null && ( + + + + {stigmataSet.name} + +
+ + Set + +
+ + {stigmataSetList.map((stigmataSetItem) => { + return ( + + ) + })} + + + + {stigmataSet.twoSetSkill.name} + + + {stigmataSet.twoSetSkill.description} + + + {stigmataSet.threeSetSkill.name} + + + {stigmataSet.threeSetSkill.description} + +
+ )} +
+
+ ) + } + const { stigmataSet, stigmataSetList } = props + return ( + - {stigmataData.name} - - - {stigmataData.name} - + {stigmataSet.name} Set - - {capitalize(stigmataData.type)} - - - {'⭐'.repeat(stigmataData.rarity)} - - - HP : {stigmataData.hp} / ATK : {stigmataData.atk} / DEF :{' '} - {stigmataData.def} / CRT : {stigmataData.crt} - + + {stigmataSetList.map((stigmataSetItem) => { + return ( + + ) + })} + + {stigmataSetList.map((stigmataSetItem) => { + return ( + + + + {stigmataSetItem.name} + + +
+ + {capitalize(stigmataSetItem.type)} + +
+ + HP : {stigmataSetItem.hp} / ATK : {stigmataSetItem.atk} / DEF + : {stigmataSetItem.def} / CRT : {stigmataSetItem.crt} + + + {stigmataSetItem.skill.description} + +
+ ) + })}
- - + - Skill - {stigmataData.skill.name} + {stigmataSet.twoSetSkill.name} - {stigmataData.skill.description} + + {stigmataSet.twoSetSkill.description} + + + {stigmataSet.threeSetSkill.name} + + + {stigmataSet.threeSetSkill.description} + - - {stigmataSet != null && ( - - - {stigmataSet.name} -
- - Set - -
- - {stigmataSetList.map((stigmataSetItem) => { - return ( - - ) - })} - - - - {stigmataSet.twoSetSkill.name} - - - {stigmataSet.twoSetSkill.description} - - - {stigmataSet.threeSetSkill.name} - - - {stigmataSet.threeSetSkill.description} - -
- )}
) @@ -133,25 +231,45 @@ export async function getStaticProps( ctx: NextPageContext & { params: { stigmataId: string } } ) { const stigmataData = getStigmataById(ctx.params.stigmataId)! - + if (stigmataData != null) { + return { + props: { + type: 'single', + stigmataData: stigmataData, + stigmataSetList: (getStigmataListBySetId(stigmataData.set!) || []).sort( + (a, b) => -a.type.localeCompare(b.type) + ), + stigmataSet: getStigmataSetBySetId(stigmataData.set!) || null, + }, + } + } + const [stigmataSetId] = ctx.params.stigmataId.split('-set') + const stigmataSet = getStigmataSetBySetId(stigmataSetId)! return { props: { - stigmataData: stigmataData, - stigmataSetList: (getStigmataListBySetId(stigmataData.set!) || []).sort( + type: 'set', + stigmataSet, + stigmataSetList: (getStigmataListBySetId(stigmataSet.id) || []).sort( (a, b) => -a.type.localeCompare(b.type) ), - stigmataSet: getStigmataSetBySetId(stigmataData.set!) || null, }, } } export async function getStaticPaths() { return { - paths: listStigmata().map((stigmata) => { - return { - params: { stigmataId: stigmata.id }, - } - }), + paths: [ + ...listStigmata().map((stigmata) => { + return { + params: { stigmataId: stigmata.id }, + } + }), + ...listStigmataSet().map((stigmataSet) => { + return { + params: { stigmataId: `${stigmataSet.id}-set` }, + } + }), + ], fallback: false, } } diff --git a/src/server/data/honkai3rd/stigmata.ts b/src/server/data/honkai3rd/stigmata.ts index 254dc9c2..020278f1 100644 --- a/src/server/data/honkai3rd/stigmata.ts +++ b/src/server/data/honkai3rd/stigmata.ts @@ -72,6 +72,10 @@ export function getStigmataById(id: string) { return stigmataMap.get(id) } +export function listStigmataSet() { + return stigmataSetList +} + export function getStigmataListBySetId(setId: string) { return stigmataSetStigmataDataListMap.get(setId) || [] }