From 688cdee398df1f277e98b422db8bdd6eb8a08fd6 Mon Sep 17 00:00:00 2001 From: Sakura Knoll Date: Wed, 12 Jul 2023 00:19:44 +0900 Subject: [PATCH] Improve stigma page to show set info --- src/lib/v2-pre/server/loadData.ts | 4 +- src/pages/v2-pre/stigmata/[stigmaId].tsx | 69 +++++++++++++++++++++--- src/pages/v2-pre/stigmata/index.tsx | 2 +- 3 files changed, 64 insertions(+), 11 deletions(-) diff --git a/src/lib/v2-pre/server/loadData.ts b/src/lib/v2-pre/server/loadData.ts index 72ee0378..c6e7be71 100644 --- a/src/lib/v2-pre/server/loadData.ts +++ b/src/lib/v2-pre/server/loadData.ts @@ -1,7 +1,7 @@ import fs from 'fs' import path from 'path' import YAML from 'yaml' -import { BattlesuitCatalogItem, Stigma, StigmataSet, WeaponCatalogItem } from '../data/types' +import { BattlesuitCatalogItem, RootStigma, StigmataSet, WeaponCatalogItem } from '../data/types' export const dataDir = path.join(process.cwd(), 'data/v2-pre') @@ -39,7 +39,7 @@ export function loadStigmataCatalog(): WeaponCatalogItem[] { return readYamlFile(stigmataCatalogPath) } -export function loadStigmaData(id: string): Stigma { +export function loadStigmaData(id: string): RootStigma { const stigmaDataPath = path.join(stigmataDir, `${id}.yaml`) return readYamlFile(stigmaDataPath) } diff --git a/src/pages/v2-pre/stigmata/[stigmaId].tsx b/src/pages/v2-pre/stigmata/[stigmaId].tsx index f1d98c60..2dccd2af 100644 --- a/src/pages/v2-pre/stigmata/[stigmaId].tsx +++ b/src/pages/v2-pre/stigmata/[stigmaId].tsx @@ -1,9 +1,9 @@ import { NextPageContext } from 'next' -import { Box, Card, Flex, Heading } from 'theme-ui' +import { Box, Card, Flex, Heading, Link } from 'theme-ui' import FormattedText from '../../../components/v2-pre/FormattedText' import { formatSubSkillInfo, replaceNewLine } from '../../../lib/v2-pre/data/formatText' -import { loadStigmaData, loadStigmataCatalog } from '../../../lib/v2-pre/server/loadData' -import { RootStigma, SkillTagItem } from '../../../lib/v2-pre/data/types' +import { loadStigmaData, loadStigmataCatalog, loadStigmataSetData } from '../../../lib/v2-pre/server/loadData' +import { RootStigma, SkillTagItem, StigmataSetCatalogItem } from '../../../lib/v2-pre/data/types' import { Fragment } from 'react' import TagIcon from '../../../components/v2-pre/TagIcon' import { getStigmaTypeLabel } from '../../../lib/v2-pre/data/text' @@ -11,19 +11,23 @@ import StigmaTypeIcon from '../../../components/v2-pre/StigmaTypeIcon' import StigmaIcon from '../../../components/v2-pre/StigmaIcon' import StigmaFigureImage from '../../../components/v2-pre/StigmaFigureImage' -interface WeaponShowPageProps { +interface StigmaShowPageProps { rootStigma: RootStigma + stigmataSetCatalogItem: StigmataSetCatalogItem | null } -const StigmaShowPage = ({ rootStigma }: WeaponShowPageProps) => { +const StigmaShowPage = ({ rootStigma, stigmataSetCatalogItem }: StigmaShowPageProps) => { const stigma = rootStigma.stigmata[rootStigma.stigmata.length - 1] return ( {stigma.name} - + + + + @@ -44,7 +48,7 @@ const StigmaShowPage = ({ rootStigma }: WeaponShowPageProps) => { Skills - + {stigma.skills.map(skill => { return ( @@ -85,6 +89,35 @@ const StigmaShowPage = ({ rootStigma }: WeaponShowPageProps) => { ) })} + + {stigmataSetCatalogItem != null && ( + <> + Set + + + + + {stigmataSetCatalogItem.stigmataList.map(stigma => { + return + })} + + + {stigmataSetCatalogItem.name} + + {/* {stigma.id} */} + + + + + )} {/*
{JSON.stringify(weapon, null, 2)}
*/}
) @@ -94,9 +127,29 @@ export default StigmaShowPage export async function getStaticProps({ locale, params }: NextPageContext & { params: { stigmaId: string } }) { const rootStigma = loadStigmaData(params.stigmaId) + const setId = rootStigma.stigmata[0].setId + + let stigmataSetCatalogItem: StigmataSetCatalogItem | null = null + if (setId !== '0') { + const stigmataSet = loadStigmataSetData(setId) + const setStigmataList = stigmataSet.stigmaIdList.map(id => { + const targetRootStigma = params.stigmaId === id ? rootStigma : loadStigmaData(id) + const maxedStigma = targetRootStigma.stigmata[targetRootStigma.stigmata.length - 1] + return { + id: targetRootStigma.id, + icon: maxedStigma.icon, + maxRarity: maxedStigma.maxRarity + } + }) + stigmataSetCatalogItem = { + id: setId, + name: stigmataSet.name, + stigmataList: setStigmataList + } + } return { - props: { rootStigma } + props: { rootStigma, stigmataSetCatalogItem } } } diff --git a/src/pages/v2-pre/stigmata/index.tsx b/src/pages/v2-pre/stigmata/index.tsx index 11b57293..e1385bca 100644 --- a/src/pages/v2-pre/stigmata/index.tsx +++ b/src/pages/v2-pre/stigmata/index.tsx @@ -14,7 +14,7 @@ interface StigmataListPageProps { const StigmataListPage = ({ stigmataCatalog }: StigmataListPageProps) => { return ( -

Stigmata

+

Stigmata (Single)

{stigmataCatalog .filter(filterStigmata)