diff --git a/legacy-redirects.js b/legacy-redirects.js new file mode 100644 index 00000000..09476fdd --- /dev/null +++ b/legacy-redirects.js @@ -0,0 +1,93 @@ +// const YAML = require('yaml') +// const fs = require('fs') +// const path = require('path') + +// const rawData = fs.readFileSync(path.join(process.cwd(), 'data/honkai3rd/battlesuits.yaml')).toString() +module.exports = [ + ['dw', 3401], + ['ta', 3501], + ['vq', 3301], + ['hof', 106], + ['hoo', 206], + ['hotr', 317], + ['cn', 3201], + ['jk', 3101], + ['hoh', 2202], + ['vill-v', 3001], + ['griseo', 2901], + ['aponia', 2701], + ['eden', 2801], + ['rc', 2601], + ['pe', 804], + ['spa', 706], + ['sw', 315], + ['sns', 2501], + ['io', 2301], + ['ma', 2401], + ['mpe', 2201], + ['hfs', 105], + ['pv', 2101], + ['nyx', 713], + ['hb', 314], + ['hos', 612], + ['bh', 901], + ['da', 803], + // ['ft'], + // ['ds'], + ['fr', 705], + ['hot', 205], + ['sa', 506], + ['bke', 802], + ['vg', 801], + ['ae', 611], + ['kasumi', 214], + // ['hf', ], + ['sn', 712], + // ['tp', ], + ['hor', 313], + // ['vd', ], + ['sp', 711], + ['bb', 421], + ['mc', 422], + // ['dk', ], + ['aka', 704], + // ['stfu', ], + ['pi', 702], + ['sj', 114], + ['ur', 703], + ['vke', 412], + ['hov', 113], + ['kriegs', 411], + ['ns', 603], + ['6s', 111], + ['lk', 511], + ['px', 604], + ['sk', 602], + ['va', 601], + ['ch', 504], + ['ri', 112], + ['bn', 312], + ['sr', 503], + ['wd', 311], + ['vp', 501], + ['ve', 502], + ['bs', 403], + ['br', 404], + ['ci', 201], + ['db', 304], + ['dp', 104], + ['fs', 213], + ['meme', 212], + ['miko', 211], + ['km', 103], + ['le', 204], + ['sf', 402], + ['sd', 202], + ['ss', 303], + ['vb', 203], + ['vc', 301], + ['vr', 102], + ['vt', 401], + ['wc', 101], + ['ya', 302] +] diff --git a/next.config.js b/next.config.js index 724606e8..1933e43d 100644 --- a/next.config.js +++ b/next.config.js @@ -1,98 +1,102 @@ const { i18n } = require('./next-i18next.config') +const legacyRedirects = require('./legacy-redirects.js') module.exports = { async redirects() { return [ + ...legacyRedirects.map(([source, dest]) => { + console.log(source, dest) + return { + source: `/honkai3rd/battlesuits/${source}`, + destination: `/honkai3rd/battlesuits/${dest}`, + permanent: false + } + }), { source: '/honkai3rd/stigmata/elysia-flawless', destination: '/honkai3rd/stigmata/elysia-pristine', - permanent: true, + permanent: true }, { source: '/honkai3rd/stigmata/elysia-flawless-top', destination: '/honkai3rd/stigmata/elysia-pristine-top', - permanent: true, + permanent: true }, { source: '/honkai3rd/stigmata/elysia-flawless-mid', destination: '/honkai3rd/stigmata/elysia-pristine-mid', - permanent: true, + permanent: true }, { source: '/honkai3rd/stigmata/elysia-flawless-bot', destination: '/honkai3rd/stigmata/elysia-pristine-bot', - permanent: true, - }, - { - source: '/honkai3rd/stigmata/elysia-flawless', - destination: '/honkai3rd/stigmata/bianka-theatre', - permanent: true, + permanent: true }, { source: '/honkai3rd/stigmata/bianka-stage-top', destination: '/honkai3rd/stigmata/bianka-theatre-top', - permanent: true, + permanent: true }, { source: '/honkai3rd/stigmata/bianka-stage-mid', destination: '/honkai3rd/stigmata/bianka-theatre-mid', - permanent: true, + permanent: true }, { source: '/honkai3rd/stigmata/bianka-stage-bot', destination: '/honkai3rd/stigmata/bianka-theatre-bot', - permanent: true, + permanent: true }, { source: '/honkai3rd/elfs/hsd', destination: '/honkai3rd/elfs/bd', - permanent: true, + permanent: true }, { source: '/honkai3rd/weapons/dream-of-the-past', destination: '/honkai3rd/weapons/purana-phantasma', - permanent: true, + permanent: true }, { source: '/honkai3rd/weapons/dream-of-the-past-eyes-of-the-night', destination: '/honkai3rd/weapons/purana-phantasma-nighteye', - permanent: true, + permanent: true }, { source: '/honkai3rd/weapons/dark-meteorite-golden-scale', destination: '/honkai3rd/weapons/gilded-librae', - permanent: true, + permanent: true }, { source: '/honkai3rd/weapons/azure-flare', destination: '/honkai3rd/weapons/cerulean-flare', - permanent: true, + permanent: true }, { source: '/honkai3rd/battlesuits/pardofelis', destination: '/honkai3rd/battlesuits/rc', - permanent: true, + permanent: true }, { source: '/honkai3rd/weapons/prisoner-of-the-past', destination: '/honkai3rd/weapons/lost-conviction', - permanent: true, + permanent: true }, { source: '/honkai3rd/weapons/prisoner-of-the-past-deed-of-fate', destination: '/honkai3rd/weapons/lost-conviction-damnation', - permanent: true, + permanent: true }, { source: '/honkai3rd/weapons/beautiful-poem-of-the-past', destination: '/honkai3rd/weapons/echo-of-paradise', - permanent: true, + permanent: true }, { source: '/novels/ae/index.html', destination: '/honkai3rd/novels/ae', - permanent: false, - }, + permanent: false + } ] }, async rewrites() { @@ -100,46 +104,46 @@ module.exports = { { source: '/ko-KR/honkai3rd/novels/ae', destination: '/novels/ae/ko-KR/index.html', - locale: false, + locale: false }, { source: '/en-US/honkai3rd/novels/ae', destination: '/novels/ae/en-US/index.html', - locale: false, + locale: false }, { source: '/honkai3rd/novels/ae', - destination: '/novels/ae/en-US/index.html', + destination: '/novels/ae/en-US/index.html' }, { source: '/ko-KR/honkai3rd/novels/duriduri', destination: '/novels/duriduri/ko-KR/index.html', - locale: false, + locale: false }, { source: '/en-US/honkai3rd/novels/duriduri', destination: '/novels/duriduri/en-US/index.html', - locale: false, + locale: false }, { source: '/honkai3rd/novels/duriduri', - destination: '/novels/duriduri/en-US/index.html', + destination: '/novels/duriduri/en-US/index.html' }, { source: '/ko-KR/honkai3rd/novels/7s', destination: '/novels/7s/ko-KR/index.html', - locale: false, + locale: false }, { source: '/en-US/honkai3rd/novels/7s', destination: '/novels/7s/en-US/index.html', - locale: false, + locale: false }, { source: '/honkai3rd/novels/7s', - destination: '/novels/7s/en-US/index.html', - }, + destination: '/novels/7s/en-US/index.html' + } ] }, - i18n, + i18n } diff --git a/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx b/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx index c75f0624..ee98ebd5 100644 --- a/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx +++ b/src/pages/honkai3rd/battlesuits/[battlesuitId].tsx @@ -1,213 +1,162 @@ -/** @jsxImportSource theme-ui */ -import { Box, Card, Flex, Heading, Paragraph, Text, Image } from '@theme-ui/components' import { NextPageContext } from 'next' -import React from 'react' -import BattlesuitFeatureLabel from '../../../components/atoms/BattlesuitFeatureLabel' -import BattlesuitRankIcon from '../../../components/atoms/BattlesuitRankIcon' -import PageLink from '../../../components/atoms/PageLink' -import SecondaryLabel from '../../../components/atoms/SecondaryLabel' -import TypeLabel from '../../../components/atoms/TypeLabel' -import ValkyrieLabel from '../../../components/atoms/ValkyrieLabel' -import Breadcrumb from '../../../components/organisms/Breadcrumb' +import { Box, Card, Flex, Heading } from 'theme-ui' +import AttributeIcon from '../../../components/v2/AttributeIcon' +import AvatarFigureImage from '../../../components/v2/AvatarFigureImage' +import AvatarSkillIcon from '../../../components/v2/AvatarSkillIcon' +import AvatarSubSkillIcon from '../../../components/v2/AvatarSubSkillIcon' +import BattlesuitAvatarIcon from '../../../components/v2/BattlesuitAvatarIcon' +import FormattedText from '../../../components/v2/FormattedText' +import { formatSkillInfo, formatSubSkillInfo } from '../../../lib/v2/data/formatText' +import { loadBattlesuitCatalog, loadBattlesuitData } from '../../../lib/v2/server/loadData' +import { Battlesuit, SkillTagItem } from '../../../lib/v2/data/types' +import { Fragment } from 'react' +import TagIcon from '../../../components/v2/TagIcon' import { - BattlesuitData, - battlesuitFeatures, - BattlesuitSkillGroup, - battlesuitTypes, - valkyries -} from '../../../lib/honkai3rd/battlesuits' -import { generateI18NPaths, getI18NProps } from '../../../server/i18n' -import { getBattlesuitById, listBattlesuits } from '../../../server/data/honkai3rd/battlesuits' -import { translate, useTranslation } from '../../../lib/i18n' -import { useRouter } from 'next/router' -import Head from '../../../components/atoms/Head' -import { capitalize } from '../../../lib/string' -import { assetsBucketBaseUrl } from '../../../lib/consts' + getAttributeLabel, + getCharacterTypeLabel, + getSkillTypeLabel, + getTagTypeLabel, + getWeaponTypeLabel +} from '../../../lib/v2/data/text' +import StarIcon from '../../../components/v2/StarIcon' +import ChibiIcon from '../../../components/v2/ChibiIcon' +import WeaponTypeIcon from '../../../components/v2/WeaponTypeIcon' +import { sortBattlesuitSkill } from '../../../lib/v2/data/utils' import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' -import { WeaponData } from '../../../lib/honkai3rd/weapons' -import { getWeaponMapByIds } from '../../../server/data/honkai3rd/weapons' -import { StigmataData } from '../../../lib/honkai3rd/stigmata' -import WeaponCard from '../../../components/molecules/WeaponCard' -import StigmataCard from '../../../components/molecules/StigmataCard' -import { getStigmataMapByIds } from '../../../server/data/honkai3rd/stigmata' - -type WeaponObjectMap = { [key: string]: WeaponData } -type StigmataObjectMap = { [key: string]: StigmataData } +import { getI18NProps } from '../../../server/i18n' +import Head from '../../../components/atoms/Head' +import { useTranslation } from 'next-i18next' interface BattlesuitShowPageProps { - battlesuit: BattlesuitData - weaponMap: WeaponObjectMap - stigmataMap: StigmataObjectMap + battlesuit: Battlesuit } -const BattlesuitShowPage = ({ battlesuit, weaponMap, stigmataMap }: BattlesuitShowPageProps) => { +const BattlesuitShowPage = ({ battlesuit }: BattlesuitShowPageProps) => { const { t } = useTranslation() - const { locale } = useRouter() - - const { label: valkyrieLabel, krLabel } = valkyries.find(aValkyrie => aValkyrie.value === battlesuit.valkyrie) || { - label: battlesuit.valkyrie, - krLabel: battlesuit.valkyrie - } - - const valkyrieName = translate(locale, { 'ko-KR': krLabel }, valkyrieLabel) - - const battlesuitType = battlesuitTypes.find(aType => aType.value === battlesuit.type) - const battlesuitTypeLabel = battlesuitType - ? translate(locale, { 'ko-KR': battlesuitType.krLabel }, battlesuitType.label) - : capitalize(battlesuit.type) - return ( { - const featureData = battlesuitFeatures.find(aFeature => aFeature.value === feature) - if (featureData == null) { - return feature - } - - const { label, krLabel } = featureData - - return translate(locale, { 'ko-KR': krLabel }, label) + title={`${battlesuit.fullName} - ${t('common.honkai-3rd')} - ${t('common.abyss-lab')}`} + description={`${t('common.honkai-3rd')} ${t('battlesuit-show.battlesuit')} / ${battlesuit.fullName} / ${ + battlesuit.attributeType + } / ${battlesuit.tags + .map(tag => { + return getTagTypeLabel(tag) }) .join(', ')}`} canonicalHref={`/honkai3rd/battlesuits/${battlesuit.id}`} /> + + {battlesuit.fullName} - - - - {battlesuit.name} + - - {battlesuit.name} - + - - - - - - - - - - - - - {battlesuit.features.map(feature => { + + + + + + + + + + + {getCharacterTypeLabel(battlesuit.character)} + + + + + {getAttributeLabel(battlesuit.attributeType)} + + + + {getWeaponTypeLabel(battlesuit.weapon)} + + + + {battlesuit.tags.map(tag => { return ( - - - - - + + + {getTagTypeLabel(tag)} + ) })} - {battlesuit.equipment != null && ( - - {battlesuit.equipment.map(equipmentItem => { - return ( - - - {t(`battlesuit-show.equipmentTypes.${equipmentItem.type}`)} + Skills + {battlesuit.skills.sort(sortBattlesuitSkill).map(skill => { + return ( + + + + + + {skill.name} - - {equipmentItem.weapon != null && } - {equipmentItem.stigmataTop != null && ( - - )} - {equipmentItem.stigmataMid != null && ( - - )} - {equipmentItem.stigmataBot != null && ( - - )} - - - ) - })} - - )} + {skill.tags.length > 0 && ( + + {skill.tags.map((tag, index) => { + return + })} + + )} + - + {getSkillTypeLabel(skill.skillType)} + + + {formatSkillInfo(skill)} + - + {skill.subSkills.map(subSkill => { + return ( + + + + + + {subSkill.name} + - + {subSkill.unlockStar.localeCompare(battlesuit.initialStar) > 0 && ( + + + + )} - + {subSkill.tags.length > 0 && ( + + {subSkill.tags.map((tag, index) => { + return + })} + + )} + + - - - - - {battlesuit.sp != null && ( - - )} + + {formatSubSkillInfo(subSkill)} + + + ) + })} + + ) + })} + {/*
{JSON.stringify(battlesuit, null, 2)}
*/}
) @@ -215,103 +164,31 @@ const BattlesuitShowPage = ({ battlesuit, weaponMap, stigmataMap }: BattlesuitSh export default BattlesuitShowPage -export async function getStaticProps({ params, locale }: NextPageContext & { params: { battlesuitId: string } }) { - const battlesuit = getBattlesuitById(params.battlesuitId, locale)! - const { weaponIds, stigmataIds } = (battlesuit.equipment || []).reduce<{ - weaponIds: string[] - stigmataIds: string[] - }>( - (acc, equipmentItem) => { - acc.weaponIds.push(equipmentItem.weapon) - acc.stigmataIds.push(equipmentItem.stigmataTop, equipmentItem.stigmataMid, equipmentItem.stigmataBot) - return acc - }, - { weaponIds: [], stigmataIds: [] } - ) - const weaponMap = getWeaponMapByIds(weaponIds, locale) - - const stigmataMap = getStigmataMapByIds(stigmataIds, locale) +export async function getStaticProps({ locale, params }: NextPageContext & { params: { battlesuitId: string } }) { + const battlesuit = loadBattlesuitData(params.battlesuitId) return { - props: { - battlesuit, - weaponMap, - stigmataMap, - ...(await getI18NProps(locale)) - } + props: { battlesuit, ...(await getI18NProps(locale)) } } } export async function getStaticPaths() { + const battlesuitCatalog = loadBattlesuitCatalog() + return { - paths: generateI18NPaths( - listBattlesuits().map(battlesuit => { - return { - params: { battlesuitId: battlesuit.id } - } - }) - ), + paths: battlesuitCatalog.map(catalogItem => { + return { + params: { battlesuitId: catalogItem.id } + } + }), fallback: false } } -interface BattlesuitSkillGroupCardProps { - heading: string - skillGroup: BattlesuitSkillGroup +interface SkillTagBoxProps { + tag: SkillTagItem } -const BattlesuitSkillGroupCard = ({ heading, skillGroup }: BattlesuitSkillGroupCardProps) => { - return ( - - - - {skillGroup.core.name} - - {heading} - - - - {skillGroup.core.description} - - - {skillGroup.subskills.map(subskill => { - return ( - - - - {subskill.name} - {subskill.requiredRank != null ? ( - /^[0-9]/.test(subskill.requiredRank) ? ( - - ⭐{subskill.requiredRank.slice(0, 1)} - - ) : ( - - ) - ) : ( - - )} - - - - - {subskill.description} - - - ) - })} - - ) +const SkillTagItem = ({ tag }: SkillTagBoxProps) => { + return } diff --git a/src/pages/honkai3rd/battlesuits/index.tsx b/src/pages/honkai3rd/battlesuits/index.tsx index c8a90b41..f938332c 100644 --- a/src/pages/honkai3rd/battlesuits/index.tsx +++ b/src/pages/honkai3rd/battlesuits/index.tsx @@ -1,76 +1,22 @@ /** @jsxImportSource theme-ui */ -import { Box, Heading, Flex, Button } from '@theme-ui/components' -import { useCallback, useMemo, useState } from 'react' -import FilterButton from '../../../components/atoms/FilterButton' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import { listBattlesuits } from '../../../server/data/honkai3rd/battlesuits' -import { BattlesuitData, battlesuitFeatures, battlesuitTypes, valkyries } from '../../../lib/honkai3rd/battlesuits' -import BattlesuitCard from '../../../components/molecules/BattlesuitCard' -import { useRouter } from 'next/router' +import { Box } from '@theme-ui/components' import { NextPageContext } from 'next' -import { getI18NProps } from '../../../server/i18n' -import { translate, useTranslation } from '../../../lib/i18n' +import { Flex, Link } from 'theme-ui' +import { loadBattlesuitCatalog } from '../../../lib/v2/server/loadData' +import { BattlesuitCatalogItem } from '../../../lib/v2/data/types' +import BattlesuitCatalogItemCard from '../../../components/v2/BattlesuitCatalogItemCard' import Head from '../../../components/atoms/Head' import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' - -type BattlesuitListItemData = Pick +import { useTranslation } from 'next-i18next' +import Breadcrumb from '../../../components/organisms/Breadcrumb' +import { getI18NProps } from '../../../server/i18n' interface BattlesuitListPageProps { - battlesuits: BattlesuitListItemData[] + battlesuitCatalog: BattlesuitCatalogItem[] } -const featureFilterOptions: { - value: string - label: string - icon?: string - krLabel?: string -}[] = [{ value: 'all', label: 'All', krLabel: '전체' }, ...battlesuitFeatures] - -const valkyrieFilterOptions: { - value: string - label: string - icon?: string - krLabel?: string -}[] = [{ value: 'all', label: 'All', krLabel: '전체' }, ...battlesuitTypes, ...valkyries] - -const BattlesuitListPage = ({ battlesuits }: BattlesuitListPageProps) => { - const { query, locale } = useRouter() +const BattlesuitListPage = ({ battlesuitCatalog }: BattlesuitListPageProps) => { const { t } = useTranslation() - const [hiddenFilters, setHiddenFilters] = useState(true) - - const closeFilters = useCallback(() => { - setHiddenFilters(true) - }, []) - - const valkyrieFilter = useMemo(() => { - if (query.valkyrie == null) { - return 'all' - } - - return typeof query.valkyrie === 'string' ? query.valkyrie : query.valkyrie[0] - }, [query]) - - const featureFilter = useMemo(() => { - if (query.feature == null) { - return 'all' - } - - return typeof query.feature === 'string' ? query.feature : query.feature[0] - }, [query]) - - const battlesuitsFiteredByValkyrie = useMemo(() => { - return battlesuits.filter(battlesuit => isValkyrieFilterMatching(battlesuit, valkyrieFilter)) - }, [battlesuits, valkyrieFilter]) - - const availableFeatureSet = battlesuitsFiteredByValkyrie.reduce((set, battlesuit) => { - battlesuit.features.forEach(feature => set.add(feature)) - return set - }, new Set()) - - const battlesuitsFilteredByFeature = useMemo(() => { - return battlesuitsFiteredByValkyrie.filter(battlesuit => isFeatureFilterMatching(battlesuit, featureFilter)) - }, [battlesuitsFiteredByValkyrie, featureFilter]) - return ( { description={t('battlesuits-list.description')} canonicalHref={`/honkai3rd/battlesuits`} /> - - + - - {t('battlesuits-list.heading')} - - - - - - {t('battlesuits-list.filter-by-valkyries')} - - {valkyrieFilterOptions.map(({ value, label, icon, krLabel }) => { - return ( - - ) - })} - - {t('battlesuits-list.filter-by-features')} - - {featureFilterOptions - .filter(filterOption => { - if (filterOption.value === 'all') { - return true - } - return availableFeatureSet.has(filterOption.value) - }) - .map(({ value, label, icon, krLabel }) => { - return ( - - ) - })} - - - - - {battlesuitsFilteredByFeature.map(battlesuit => { - return +

{t('battlesuits-list.heading')}

+ + {battlesuitCatalog.map(battlesuit => { + return ( + + + + + + ) })}
@@ -171,67 +54,9 @@ const BattlesuitListPage = ({ battlesuits }: BattlesuitListPageProps) => { export default BattlesuitListPage export async function getStaticProps({ locale }: NextPageContext) { + const battlesuitCatalog = loadBattlesuitCatalog() + return { - props: { - battlesuits: listBattlesuits(locale).map(battlesuit => { - return { - id: battlesuit.id, - name: battlesuit.name, - features: battlesuit.features, - type: battlesuit.type, - valkyrie: battlesuit.valkyrie - } - }), - ...(await getI18NProps(locale)) - } + props: { battlesuitCatalog, ...(await getI18NProps(locale)) } } } - -function isValkyrieFilterMatching(battlesuit: BattlesuitListItemData, valkyrieFilter: string) { - switch (valkyrieFilter) { - case 'mecha': - case 'biologic': - case 'psychic': - case 'quantum': - case 'imaginary': - return battlesuit.type === valkyrieFilter - case 'kiana': - case 'mei': - case 'bronya': - case 'himeko': - case 'theresa': - case 'fuhua': - case 'rita': - case 'sakura': - case 'kallen': - case 'olenyevas': - case 'seele': - case 'durandal': - case 'fischl': - case 'elysia': - case 'mobius': - case 'raven': - case 'carole': - case 'asuka': - case 'pardofelis': - case 'aponia': - case 'eden': - case 'griseo': - case 'sushang': - case 'ai': - case 'susannah': - case 'misteln': - case 'prometheus': - return battlesuit.valkyrie === valkyrieFilter - default: - case 'all': - return true - } -} - -function isFeatureFilterMatching(battlesuit: BattlesuitListItemData, featureFilter: string) { - if (featureFilter === 'all') { - return true - } - return battlesuit.features.some(feature => feature === featureFilter) -} diff --git a/src/pages/honkai3rd/elfs/[elfId].tsx b/src/pages/honkai3rd/elfs/[elfId].tsx index 901ab90b..c2c97b6b 100644 --- a/src/pages/honkai3rd/elfs/[elfId].tsx +++ b/src/pages/honkai3rd/elfs/[elfId].tsx @@ -1,164 +1,117 @@ -/** @jsxImportSource theme-ui */ -import { - Box, - Card, - Flex, - Heading, - Paragraph, - Image, -} from '@theme-ui/components' import { NextPageContext } from 'next' -import React from 'react' -import BattlesuitFeatureLabel from '../../../components/atoms/BattlesuitFeatureLabel' -import SecondaryLabel from '../../../components/atoms/SecondaryLabel' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import { ElfData } from '../../../lib/honkai3rd/elfs' -import { getElfById, listElfs } from '../../../server/data/honkai3rd/elfs' -import { generateI18NPaths, getI18NProps } from '../../../server/i18n' -import { translate, useTranslation } from '../../../lib/i18n' -import { useRouter } from 'next/router' -import Head from '../../../components/atoms/Head' -import { battlesuitFeatures } from '../../../lib/honkai3rd/battlesuits' +import { Box, Card, Flex, Heading } from 'theme-ui' +import { useMemo } from 'react' +import { Elf, ElfSkill } from '../../../lib/v2/data/types' +import { loadElfCatalog, loadElfData } from '../../../lib/v2/server/loadData' +import SquareImage from '../../../components/v2/SquareImage' +import TagIcon from '../../../components/v2/TagIcon' import { assetsBucketBaseUrl } from '../../../lib/consts' -import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' +import { ListMap } from '../../../lib/utils' +import FormattedText from '../../../components/v2/FormattedText' +import { formatSubSkillInfo } from '../../../lib/v2/data/formatText' interface ElfShowPageProps { - elf: ElfData + elf: Elf } const ElfShowPage = ({ elf }: ElfShowPageProps) => { - const { locale } = useRouter() - const { t } = useTranslation() + const skillRows = useMemo(() => { + const rowSkillListMap = elf.skills.reduce>((map, skill) => { + map.set(skill.row.toString(), skill) + return map + }, new ListMap()) + return [...rowSkillListMap.values()] + }, [elf.skills]) return ( - - { - const featureData = battlesuitFeatures.find( - (aFeature) => aFeature.value === feature - ) - if (featureData == null) { - return feature - } - - const { label, krLabel } = featureData - - return translate(locale, { 'ko-KR': krLabel }, label) - }) - .join(', ')}`} - canonicalHref={`/honkai3rd/elfs/${elf.id}`} + + {elf.fullName} + - - - - {elf.name} - - - - {elf.name} - - - - - - {'⭐'.repeat(elf.baseRank)} - - - {elf.features.map((feature) => ( - - - - ))} + + + + {elf.tags.map(tag => { + return ( + + + + ) + })} - + + + Ult CD: {elf.ultSkillCd} / Ult SP Cost: {elf.ultSkillCost} + + - {elf.skillRows.map((row, rowIndex) => { - return ( - - {row.map((item, columnIndex) => { - return ( - - - - {item.name} + Skills + + {skillRows.map((row, index) => { + return ( + + {row.map(skill => { + return ( + + + + + + + + {skill.name} - - {t(`elfs-show.${item.type}`)}{' '} - {'⭐'.repeat(item.requiredRank)} - - - - {item.description} - - - ) - })} - - ) - })} - - + {/* {skill.id} */} + ({skill.skillType}) + +
+ + {formatSubSkillInfo(skill)} + + + ) + })} + + ) + })} + ) } export default ElfShowPage -export async function getStaticProps({ - params, - locale, -}: NextPageContext & { params: { elfId: string } }) { - const elf = getElfById(params.elfId, locale) +export async function getStaticProps({ locale, params }: NextPageContext & { params: { elfId: string } }) { + const elf = loadElfData(params.elfId) + return { - props: { elf, ...(await getI18NProps(locale)) }, + props: { elf } } } export async function getStaticPaths() { + const elfCatalog = loadElfCatalog() + return { - paths: generateI18NPaths( - listElfs().map((elf) => { - return { - params: { elfId: elf.id }, - } - }) - ), - fallback: false, + paths: elfCatalog.map(catalogItem => { + return { + params: { elfId: catalogItem.id } + } + }), + fallback: false } } diff --git a/src/pages/honkai3rd/elfs/index.tsx b/src/pages/honkai3rd/elfs/index.tsx index 74d95ad6..16362034 100644 --- a/src/pages/honkai3rd/elfs/index.tsx +++ b/src/pages/honkai3rd/elfs/index.tsx @@ -1,64 +1,61 @@ /** @jsxImportSource theme-ui */ -import { Box, Heading, Flex } from '@theme-ui/components' +import { Box, Card } from '@theme-ui/components' import { NextPageContext } from 'next' -import { pick } from 'ramda' -import ElfCard from '../../../components/molecules/ElfCard' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import { ElfData } from '../../../lib/honkai3rd/elfs' -import { getI18NProps } from '../../../server/i18n' -import { listElfs } from '../../../server/data/honkai3rd/elfs' -import { useTranslation } from '../../../lib/i18n' -import Head from '../../../components/atoms/Head' -import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' +import { Flex, Link } from 'theme-ui' +import { ElfCatalogItem } from '../../../lib/v2/data/types' +import { loadElfCatalog } from '../../../lib/v2/server/loadData' +import RarityBar from '../../../components/v2/RarityBar' +import ElfIcon from '../../../components/v2/ElfIcon' interface ElfListPageProps { - elfs: Pick[] + elfs: ElfCatalogItem[] } const ElfListPage = ({ elfs }: ElfListPageProps) => { - const { t } = useTranslation() - return ( - - - - + +

Elfs

+ + {elfs + .sort((a, b) => { + const aId = getId(a.id) + const bId = getId(b.id) + return bId - aId - {t('elfs-list.elfs')} - - - {elfs.map((elf) => { - return + function getId(id: string): number { + return parseInt(id) + } + }) + .map(elf => { + return ( + + + + + + + + + {elf.fullName} + + + + + ) })} - -
-
+ + ) } export default ElfListPage export async function getStaticProps({ locale }: NextPageContext) { + const elfs = loadElfCatalog() + return { - props: { - elfs: listElfs(locale).map((elf) => pick(['id', 'name', 'krName'], elf)), - ...(await getI18NProps(locale)), - }, + props: { elfs } } } diff --git a/src/pages/honkai3rd/elysian-realm/battlesuits/[battlesuitId].tsx b/src/pages/honkai3rd/elysian-realm/battlesuits/[battlesuitId].tsx deleted file mode 100644 index 1845082b..00000000 --- a/src/pages/honkai3rd/elysian-realm/battlesuits/[battlesuitId].tsx +++ /dev/null @@ -1,139 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box, Heading, Image } from '@theme-ui/components' -import { NextPageContext } from 'next' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' -import { BattlesuitData } from '../../../../lib/honkai3rd/battlesuits' -import { generateI18NPaths, getI18NProps } from '../../../../server/i18n' -import { getBattlesuitById } from '../../../../server/data/honkai3rd/battlesuits' -import { useTranslation } from '../../../../lib/i18n' -import Head from '../../../../components/atoms/Head' -import { assetsBucketBaseUrl } from '../../../../lib/consts' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import { WeaponData } from '../../../../lib/honkai3rd/weapons' -import { getWeaponMapByIds } from '../../../../server/data/honkai3rd/weapons' -import { StigmataData } from '../../../../lib/honkai3rd/stigmata' -import { getStigmataMapByIds } from '../../../../server/data/honkai3rd/stigmata' -import { getSignetGroupById } from '../../../../server/data/honkai3rd/elysianRealm' -import { erBattlesuits, SignetSet } from '../../../../lib/honkai3rd/elysianRealm' -import SignetCard from '../../../../components/molecules/SignetCard' - -type WeaponObjectMap = { [key: string]: WeaponData } -type StigmataObjectMap = { [key: string]: StigmataData } - -interface BattlesuitShowPageProps { - battlesuit: BattlesuitData - weaponMap: WeaponObjectMap - stigmataMap: StigmataObjectMap - signetSet: SignetSet -} - -const BattlesuitShowPage = ({ battlesuit, weaponMap, stigmataMap, signetSet }: BattlesuitShowPageProps) => { - const { t } = useTranslation() - return ( - - - - - - - {battlesuit.name} - - - - {battlesuit.name} - - - - {t('elysian-realm.exclusive-signets')} - - - {signetSet.signets.map(signet => { - return - })} - - - - ) -} - -export default BattlesuitShowPage - -export async function getStaticProps({ params, locale }: NextPageContext & { params: { battlesuitId: string } }) { - try { - const battlesuit = getBattlesuitById(params.battlesuitId, locale)! - const { weaponIds, stigmataIds } = (battlesuit.equipment || []).reduce<{ - weaponIds: string[] - stigmataIds: string[] - }>( - (acc, equipmentItem) => { - acc.weaponIds.push(equipmentItem.weapon) - acc.stigmataIds.push(equipmentItem.stigmataTop, equipmentItem.stigmataMid, equipmentItem.stigmataBot) - return acc - }, - { weaponIds: [], stigmataIds: [] } - ) - const weaponMap = getWeaponMapByIds(weaponIds) - - const stigmataMap = getStigmataMapByIds(stigmataIds) - - const signetGroup = getSignetGroupById('elysia', locale) - const signetSet = signetGroup.sets.find(set => { - return set.id === `elysia-${params.battlesuitId}` - }) - - return { - props: { - battlesuit, - weaponMap, - stigmataMap, - signetSet, - ...(await getI18NProps(locale)) - } - } - } catch (error) { - console.log(error) - } -} - -export async function getStaticPaths() { - return { - paths: generateI18NPaths( - erBattlesuits.map(battlesuitId => { - return { - params: { battlesuitId: battlesuitId } - } - }) - ), - fallback: false - } -} diff --git a/src/pages/honkai3rd/elysian-realm/index.tsx b/src/pages/honkai3rd/elysian-realm/index.tsx deleted file mode 100644 index b1718779..00000000 --- a/src/pages/honkai3rd/elysian-realm/index.tsx +++ /dev/null @@ -1,198 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box, Heading, Flex, Card, Text } from '@theme-ui/components' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import { getBattlesuitMapByIds } from '../../../server/data/honkai3rd/battlesuits' -import { BattlesuitData } from '../../../lib/honkai3rd/battlesuits' -import BattlesuitCard from '../../../components/molecules/BattlesuitCard' -import { NextPageContext } from 'next' -import { getI18NProps } from '../../../server/i18n' -import { useTranslation } from '../../../lib/i18n' -import Head from '../../../components/atoms/Head' -import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' -import { erVersions } from '../../../lib/honkai3rd/elysianRealm' -import SquareImageBox from '../../../components/atoms/SquareImageBox' -import { assetsBucketBaseUrl } from '../../../lib/consts' -import PageLink from '../../../components/atoms/PageLink' -import SignetGroupNavigator from '../../../components/organisms/SignetGroupNavigator' -import { - getRemembranceSigils as getRemembranceSigils, - getSupportBattlesuits, -} from '../../../server/data/honkai3rd/elysianRealm' -import Link from 'next/link' - -type BattlesuitListItemData = Pick< - BattlesuitData, - 'id' | 'name' | 'features' | 'type' | 'valkyrie' -> - -interface BattlesuitListPageProps { - battlesuitMap: { [id: string]: BattlesuitListItemData } - supportBattlesuits: { id: string; name: string }[] - remembranceSigils: { id: string; name: string }[] -} - -const ElysianRealmIndexPage = ({ - battlesuitMap, - supportBattlesuits, - remembranceSigils, -}: BattlesuitListPageProps) => { - const { t } = useTranslation() - - return ( - - - - - - - {t('common.elysian-realm')} - - {t('common.battlesuits')} - - - {erVersions.map((erVersion) => { - return ( - - - {erVersion.version} - - - {erVersion.battlesuits.map((battlesuitId) => { - return ( - - - - ) - })} - - - ) - })} - - - - {t('elysian-realm.signets')} - - - - - - {t('elysian-realm.supports')} - - - {supportBattlesuits.map((battlesuit) => { - return ( - - - - ) - })} - - - - - {t('elysian-realm.remembrance-sigil')} - - - {remembranceSigils.map(({ id, name }) => { - return ( - - - - - - {name} - - - - - ) - })} - - - - - Guide Generator (KR Only) - - - - - ) -} - -export default ElysianRealmIndexPage - -export async function getStaticProps({ locale }: NextPageContext) { - const erBattlesuitIds = erVersions.reduce((list, version) => { - list.push(...version.battlesuits) - return list - }, []) - - const supportBattlesuits = getSupportBattlesuits(locale).map( - ({ id, name }) => { - return { - id, - name, - } - } - ) - - const remembranceSigils = getRemembranceSigils(locale).map(({ id, name }) => { - return { - id, - name, - } - }) - - return { - props: { - battlesuitMap: getBattlesuitMapByIds(erBattlesuitIds, locale), - supportBattlesuits, - remembranceSigils, - ...(await getI18NProps(locale)), - }, - } -} diff --git a/src/pages/honkai3rd/elysian-realm/remembrance-sigils.tsx b/src/pages/honkai3rd/elysian-realm/remembrance-sigils.tsx deleted file mode 100644 index 801d1312..00000000 --- a/src/pages/honkai3rd/elysian-realm/remembrance-sigils.tsx +++ /dev/null @@ -1,96 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box, Heading, Flex, Card, Paragraph } from '@theme-ui/components' -import Breadcrumb from '../../../components/organisms/Breadcrumb' - -import { NextPageContext } from 'next' -import { getI18NProps } from '../../../server/i18n' -import { useTranslation } from '../../../lib/i18n' -import Head from '../../../components/atoms/Head' -import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' -import { RemembranceSigil } from '../../../lib/honkai3rd/elysianRealm' -import SquareImageBox from '../../../components/atoms/SquareImageBox' -import { assetsBucketBaseUrl } from '../../../lib/consts' -import { getRemembranceSigils } from '../../../server/data/honkai3rd/elysianRealm' - -interface BattlesuitListPageProps { - remembranceSigils: RemembranceSigil[] -} - -const ElysianRealmIndexPage = ({ - remembranceSigils, -}: BattlesuitListPageProps) => { - const { t } = useTranslation() - - return ( - - - - - - - - {t('elysian-realm.remembrance-sigil')} - - - - {remembranceSigils.map(({ id, name, description }) => { - return ( - - - - - - - {name} - - - {description} - - - - - ) - })} - - - - ) -} - -export default ElysianRealmIndexPage - -export async function getStaticProps({ locale }: NextPageContext) { - const remembranceSigils = getRemembranceSigils(locale) - - return { - props: { - remembranceSigils, - ...(await getI18NProps(locale)), - }, - } -} diff --git a/src/pages/honkai3rd/elysian-realm/signets/[signetId].tsx b/src/pages/honkai3rd/elysian-realm/signets/[signetId].tsx deleted file mode 100644 index c2ee079d..00000000 --- a/src/pages/honkai3rd/elysian-realm/signets/[signetId].tsx +++ /dev/null @@ -1,132 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box, Heading, Flex, Text } from '@theme-ui/components' -import { NextPageContext } from 'next' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' - -import { generateI18NPaths, getI18NProps } from '../../../../server/i18n' -import { useTranslation } from '../../../../lib/i18n' -import Head from '../../../../components/atoms/Head' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import { - PopulatedSignetGroup, - signetGroups, -} from '../../../../lib/honkai3rd/elysianRealm' -import { getSignetGroupById } from '../../../../server/data/honkai3rd/elysianRealm' -import SignetCard from '../../../../components/molecules/SignetCard' -import SignetGroupNavigator from '../../../../components/organisms/SignetGroupNavigator' -import SquareImageBox from '../../../../components/atoms/SquareImageBox' -import { assetsBucketBaseUrl } from '../../../../lib/consts' -import PageLink from '../../../../components/atoms/PageLink' - -interface SignetShowPageProps { - signetId: string - signetGroup: PopulatedSignetGroup -} - -const SignetShowPage = ({ signetId, signetGroup }: SignetShowPageProps) => { - const { t } = useTranslation() - - return ( - - - - - - - - - - - {' '} - {signetGroup.altName}({signetGroup.name}) {t('elysian-realm.signets')} - - - {signetGroup.sets.map((set) => { - const signetType = set.id.split('-')[1] - return ( - - - {signetGroup.id === 'elysia' ? ( - - - - {set.name} - - - ) : ( - set.name - )} - - - {set.signets.map((signet) => { - return - })} - - - ) - })} - - - ) -} - -export default SignetShowPage - -export async function getStaticProps({ - params, - locale, -}: NextPageContext & { params: { signetId: string } }) { - const { signetId } = params - - return { - props: { - signetId, - signetGroup: getSignetGroupById(signetId, locale), - ...(await getI18NProps(locale)), - }, - } -} - -export async function getStaticPaths() { - return { - paths: generateI18NPaths( - signetGroups.map((signet) => { - return { - params: { signetId: signet.id }, - } - }) - ), - fallback: false, - } -} diff --git a/src/pages/honkai3rd/elysian-realm/support-battlesuits.tsx b/src/pages/honkai3rd/elysian-realm/support-battlesuits.tsx deleted file mode 100644 index 3f29463e..00000000 --- a/src/pages/honkai3rd/elysian-realm/support-battlesuits.tsx +++ /dev/null @@ -1,106 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { - Box, - Heading, - Flex, - Card, - Paragraph, - Badge, -} from '@theme-ui/components' -import Breadcrumb from '../../../components/organisms/Breadcrumb' - -import { NextPageContext } from 'next' -import { getI18NProps } from '../../../server/i18n' -import { useTranslation } from '../../../lib/i18n' -import Head from '../../../components/atoms/Head' -import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' -import { SupportBattlesuit } from '../../../lib/honkai3rd/elysianRealm' -import SquareImageBox from '../../../components/atoms/SquareImageBox' -import { assetsBucketBaseUrl } from '../../../lib/consts' -import { getSupportBattlesuits } from '../../../server/data/honkai3rd/elysianRealm' - -interface BattlesuitListPageProps { - supportBattlesuits: SupportBattlesuit[] -} - -const ElysianRealmIndexPage = ({ - supportBattlesuits, -}: BattlesuitListPageProps) => { - const { t } = useTranslation() - - return ( - - - - - - - - {t('elysian-realm.supports')} - - - - {supportBattlesuits.map( - ({ id, name, skillName, description, cooldown }) => { - return ( - - - - - - - {name} - {skillName} - - Cooldown: {cooldown}s - - {description} - - - - - ) - } - )} - - - - ) -} - -export default ElysianRealmIndexPage - -export async function getStaticProps({ locale }: NextPageContext) { - const supportBattlesuits = getSupportBattlesuits(locale) - - return { - props: { - supportBattlesuits, - ...(await getI18NProps(locale)), - }, - } -} diff --git a/src/pages/honkai3rd/elysian-realm/utils/gen-guide.tsx b/src/pages/honkai3rd/elysian-realm/utils/gen-guide.tsx deleted file mode 100644 index e9b173cd..00000000 --- a/src/pages/honkai3rd/elysian-realm/utils/gen-guide.tsx +++ /dev/null @@ -1,97 +0,0 @@ -/* eslint-disable @next/next/no-page-custom-font */ -import { NextPageContext } from 'next' -import { useRouter } from 'next/router' -import { pick } from 'ramda' -import { Box, Button, Flex, Heading } from 'theme-ui' -import ERGuideGenerator from '../../../../components/organisms/ERGuideGenerator/ERGuideGenerator' -import { BattlesuitData } from '../../../../lib/honkai3rd/battlesuits' -import { - PopulatedSignetGroup, - RemembranceSigil, -} from '../../../../lib/honkai3rd/elysianRealm' -import { WeaponData } from '../../../../lib/honkai3rd/weapons' -import { StigmataData } from '../../../../lib/honkai3rd/stigmata' -import { listBattlesuits } from '../../../../server/data/honkai3rd/battlesuits' -import { - getRemembranceSigils, - getSignetGroupById, -} from '../../../../server/data/honkai3rd/elysianRealm' -import { listStigmata } from '../../../../server/data/honkai3rd/stigmata' -import { listWeapons } from '../../../../server/data/honkai3rd/weapons' -import { getI18NProps } from '../../../../server/i18n' -import Head from '../../../../components/atoms/Head' -import { useTranslation } from 'next-i18next' - -interface GenerateGuidePageProps { - weapons: WeaponData[] - stigmata: StigmataData[] - battlesuits: BattlesuitData[] - exSignetGroup: PopulatedSignetGroup - sigils: RemembranceSigil[] -} - -const GenerateGuidePage = ({ - weapons, - stigmata, - battlesuits, - exSignetGroup, - sigils, -}: GenerateGuidePageProps) => { - const router = useRouter() - const { t } = useTranslation() - - return ( - - - - - ER Guide Generator - - - - ) -} - -export default GenerateGuidePage - -export async function getStaticProps({ locale }: NextPageContext) { - return { - props: { - weapons: listWeapons('ko-KR').map((weapon) => { - return pick(['name', 'id', 'rarity', 'category'], weapon) - }), - stigmata: listStigmata('ko-KR').map((stigmata) => { - return pick(['name', 'id', 'type'], stigmata) - }), - battlesuits: listBattlesuits('ko-KR').map((battlesuit) => { - return { - id: battlesuit.id, - name: battlesuit.name, - type: battlesuit.type, - valkyrie: battlesuit.valkyrie, - } - }), - exSignetGroup: getSignetGroupById('elysia', 'ko-KR'), - sigils: getRemembranceSigils('ko-KR'), - ...(await getI18NProps('ko-KR')), - }, - } -} diff --git a/src/pages/honkai3rd/enemies/index.tsx b/src/pages/honkai3rd/enemies/index.tsx deleted file mode 100644 index 8cf79f90..00000000 --- a/src/pages/honkai3rd/enemies/index.tsx +++ /dev/null @@ -1,180 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box, Heading } from '@theme-ui/components' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import { NextPageContext } from 'next' -import { getI18NProps } from '../../../server/i18n' -import { useTranslation } from '../../../lib/i18n' -import Head from '../../../components/atoms/Head' -import { useCallback, useEffect, useMemo, useRef, useState } from 'react' -import { times } from 'ramda' -import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' - -const enemyIdList = [ - ...times((i) => i + 0, 1000).map((i) => { - const stringified = i.toString() - return `BOSS_${'0'.repeat(3 - stringified.length) + stringified}` - }), - // ...times((i) => i + 65, 26) - // .reduce<[number, number][]>((array, first) => { - // array.push( - // ...times((i) => i + 65, 26).map<[number, number]>((second) => [ - // first, - // second, - // ]) - // ) - // return array - // }, []) - // .map(([first, second]) => { - // return String.fromCharCode(first) + String.fromCharCode(second) - // }) - // .reduce((idList, prefix) => { - // idList.push( - // ...times((i) => i + 12, 1).map((i) => { - // const stringified = i.toString() - // return `${prefix}_${'0'.repeat(3 - stringified.length) + stringified}` - // }) - // ) - // return idList - // }, []), -] - -// console.log( -// times((i) => i + 65, 26) -// .reduce<[number, number][]>((array, first) => { -// array.push( -// ...times((i) => i + 65, 26).map<[number, number]>((second) => [ -// first, -// second, -// ]) -// ) -// return array -// }, []) -// .map(([first, second]) => { -// return String.fromCharCode(first) + String.fromCharCode(second) -// }) -// .reduce((idList, prefix) => { -// idList.push( -// ...times((i) => i + 10, 1).map((i) => { -// const stringified = i.toString() -// return `${prefix}_${'0'.repeat(3 - stringified.length) + stringified}` -// }) -// ) -// return idList -// }, []) -// ) - -// console.log( -// times(i => i + 65, 26).map(code => { -// return [...times((i) => i + 10, 10).map((i) => { -// const stringified = i.toString() -// return `_${'0'.repeat(3 - stringified.length) + stringified}` -// })] -// }) -// ) - -const Honkai3rdIndexPage = () => { - const { t } = useTranslation() - const [validList, setValidList] = useState([]) - const validMap = useMemo(() => { - return new Map(validList.map((id) => [id, id])) - }, [validList]) - const initializedRef = useRef(false) - - const appendValidList = useCallback((enemyId: string) => { - setValidList((previousList) => { - return [...previousList, enemyId] - }) - }, []) - - useEffect(() => { - let data = validList - if (!initializedRef.current) { - initializedRef.current = true - let rawValidEnemyIdList = localStorage.getItem('valid-enemy-id-list') - try { - console.log('load') - data = JSON.parse(rawValidEnemyIdList || '[]') - if (!Array.isArray(data)) { - throw new Error('data must be array') - } - } catch (error) { - console.warn(error) - data = [] - } - setValidList(data) - return - } - - console.log('save') - localStorage.setItem('valid-enemy-id-list', JSON.stringify(data)) - }, [validList]) - - return ( - - - - - - Enemies - - - - {enemyIdList - .filter((enemyId) => !validMap.get(enemyId)) - .map((enemyId) => { - return ( - - {enemyId} - - - ) - })} - -

Valid

- - {validList.map((enemyId) => { - return ( - - {enemyId} - {enemyId} - - - ) - })} - -
- ) -} - -export async function getStaticProps({ locale }: NextPageContext) { - return { - props: { - ...(await getI18NProps(locale)), - }, - } -} - -export default Honkai3rdIndexPage diff --git a/src/pages/honkai3rd/v2/er/battlesuits/[battlesuitId].tsx b/src/pages/honkai3rd/er/battlesuits/[battlesuitId].tsx similarity index 88% rename from src/pages/honkai3rd/v2/er/battlesuits/[battlesuitId].tsx rename to src/pages/honkai3rd/er/battlesuits/[battlesuitId].tsx index 78f2a8e8..0557f972 100644 --- a/src/pages/honkai3rd/v2/er/battlesuits/[battlesuitId].tsx +++ b/src/pages/honkai3rd/er/battlesuits/[battlesuitId].tsx @@ -1,16 +1,16 @@ import { NextPageContext } from 'next' import { Box, Card, Flex, Heading, Image, Link } from 'theme-ui' -import AvatarFigureImage from '../../../../../components/v2/AvatarFigureImage' -import { loadBattlesuitData, loadErBattlesuit, loadErBattlesuitCatalog } from '../../../../../lib/v2/server/loadData' -import { Battlesuit, ErBattlesuit, ErSignet } from '../../../../../lib/v2/data/types' +import AvatarFigureImage from '../../../../components/v2/AvatarFigureImage' +import { loadBattlesuitData, loadErBattlesuit, loadErBattlesuitCatalog } from '../../../../lib/v2/server/loadData' +import { Battlesuit, ErBattlesuit, ErSignet } from '../../../../lib/v2/data/types' import { Fragment, useMemo } from 'react' -import { assetsBucketBaseUrl } from '../../../../../lib/consts' -import BattlesuitCatalogItemCard from '../../../../../components/v2/BattlesuitCatalogItemCard' -import Honkai3rdLayout from '../../../../../components/layouts/Honkai3rdLayout' -import Head from '../../../../../components/atoms/Head' +import { assetsBucketBaseUrl } from '../../../../lib/consts' +import BattlesuitCatalogItemCard from '../../../../components/v2/BattlesuitCatalogItemCard' +import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' +import Head from '../../../../components/atoms/Head' import { useTranslation } from 'next-i18next' -import Breadcrumb from '../../../../../components/organisms/Breadcrumb' -import { getI18NProps } from '../../../../../server/i18n' +import Breadcrumb from '../../../../components/organisms/Breadcrumb' +import { getI18NProps } from '../../../../server/i18n' interface BattlesuitShowPageProps { battlesuit: Battlesuit diff --git a/src/pages/honkai3rd/v2/er/index.tsx b/src/pages/honkai3rd/er/index.tsx similarity index 86% rename from src/pages/honkai3rd/v2/er/index.tsx rename to src/pages/honkai3rd/er/index.tsx index fac6aed2..f07c3a56 100644 --- a/src/pages/honkai3rd/v2/er/index.tsx +++ b/src/pages/honkai3rd/er/index.tsx @@ -6,20 +6,20 @@ import { loadErBattlesuitCatalog, loadErSigils, loadErSupports -} from '../../../../lib/v2/server/loadData' -import { BattlesuitCatalogItem, ErBattlesuitCatalogItem } from '../../../../lib/v2/data/types' +} from '../../../lib/v2/server/loadData' +import { BattlesuitCatalogItem, ErBattlesuitCatalogItem } from '../../../lib/v2/data/types' import { useMemo } from 'react' -import BattlesuitCatalogItemCard from '../../../../components/v2/BattlesuitCatalogItemCard' -import { assetsBucketBaseUrl } from '../../../../lib/consts' -import SquareImage from '../../../../components/v2/SquareImage' -import { signetGroups } from '../../../../lib/v2/data/er' -import BattlesuitSmallIcon from '../../../../components/v2/BattlesuitSmallIcon' -import MaterialIcon from '../../../../components/v2/MaterialIcon' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import Head from '../../../../components/atoms/Head' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' +import BattlesuitCatalogItemCard from '../../../components/v2/BattlesuitCatalogItemCard' +import { assetsBucketBaseUrl } from '../../../lib/consts' +import SquareImage from '../../../components/v2/SquareImage' +import { signetGroups } from '../../../lib/v2/data/er' +import BattlesuitSmallIcon from '../../../components/v2/BattlesuitSmallIcon' +import MaterialIcon from '../../../components/v2/MaterialIcon' +import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' +import Head from '../../../components/atoms/Head' +import Breadcrumb from '../../../components/organisms/Breadcrumb' import { useTranslation } from 'next-i18next' -import { getI18NProps } from '../../../../server/i18n' +import { getI18NProps } from '../../../server/i18n' interface ErPageProps { erBattlesuitCatalog: ErBattlesuitCatalogItem[] diff --git a/src/pages/honkai3rd/v2/er/sigils.tsx b/src/pages/honkai3rd/er/sigils.tsx similarity index 82% rename from src/pages/honkai3rd/v2/er/sigils.tsx rename to src/pages/honkai3rd/er/sigils.tsx index 6360db63..f8bf4b82 100644 --- a/src/pages/honkai3rd/v2/er/sigils.tsx +++ b/src/pages/honkai3rd/er/sigils.tsx @@ -1,13 +1,13 @@ import { NextPageContext } from 'next' import { useTranslation } from 'next-i18next' import { Box, Card, Flex, Heading } from 'theme-ui' -import Head from '../../../../components/atoms/Head' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' -import MaterialIcon from '../../../../components/v2/MaterialIcon' -import { ErSigil } from '../../../../lib/v2/data/types' -import { loadErSigils } from '../../../../lib/v2/server/loadData' -import { getI18NProps } from '../../../../server/i18n' +import Head from '../../../components/atoms/Head' +import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' +import Breadcrumb from '../../../components/organisms/Breadcrumb' +import MaterialIcon from '../../../components/v2/MaterialIcon' +import { ErSigil } from '../../../lib/v2/data/types' +import { loadErSigils } from '../../../lib/v2/server/loadData' +import { getI18NProps } from '../../../server/i18n' interface SigilsPageProps { erSigils: ErSigil[] diff --git a/src/pages/honkai3rd/v2/er/signets/[groupId].tsx b/src/pages/honkai3rd/er/signets/[groupId].tsx similarity index 83% rename from src/pages/honkai3rd/v2/er/signets/[groupId].tsx rename to src/pages/honkai3rd/er/signets/[groupId].tsx index df509832..912f70b3 100644 --- a/src/pages/honkai3rd/v2/er/signets/[groupId].tsx +++ b/src/pages/honkai3rd/er/signets/[groupId].tsx @@ -1,17 +1,17 @@ import { NextPageContext } from 'next' import { Box, Card, Flex, Heading } from 'theme-ui' -import { loadErSignets } from '../../../../../lib/v2/server/loadData' -import { ErSignet, ErSignetGroup } from '../../../../../lib/v2/data/types' +import { loadErSignets } from '../../../../lib/v2/server/loadData' +import { ErSignet, ErSignetGroup } from '../../../../lib/v2/data/types' import { Fragment, useMemo } from 'react' -import { assetsBucketBaseUrl } from '../../../../../lib/consts' -import { signetGroups } from '../../../../../lib/v2/data/er' -import SquareImage from '../../../../../components/v2/SquareImage' -import { getErSignetTypeLabel } from '../../../../../lib/v2/data/text' -import Honkai3rdLayout from '../../../../../components/layouts/Honkai3rdLayout' -import Head from '../../../../../components/atoms/Head' +import { assetsBucketBaseUrl } from '../../../../lib/consts' +import { signetGroups } from '../../../../lib/v2/data/er' +import SquareImage from '../../../../components/v2/SquareImage' +import { getErSignetTypeLabel } from '../../../../lib/v2/data/text' +import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' +import Head from '../../../../components/atoms/Head' import { useTranslation } from 'next-i18next' -import Breadcrumb from '../../../../../components/organisms/Breadcrumb' -import { getI18NProps } from '../../../../../server/i18n' +import Breadcrumb from '../../../../components/organisms/Breadcrumb' +import { getI18NProps } from '../../../../server/i18n' interface BattlesuitShowPageProps { group: ErSignetGroup diff --git a/src/pages/honkai3rd/v2/er/supports.tsx b/src/pages/honkai3rd/er/supports.tsx similarity index 87% rename from src/pages/honkai3rd/v2/er/supports.tsx rename to src/pages/honkai3rd/er/supports.tsx index 05f63def..b548cb7f 100644 --- a/src/pages/honkai3rd/v2/er/supports.tsx +++ b/src/pages/honkai3rd/er/supports.tsx @@ -2,13 +2,13 @@ import { NextPageContext } from 'next' import { useTranslation } from 'next-i18next' import { useMemo } from 'react' import { Box, Card, Flex, Heading } from 'theme-ui' -import Head from '../../../../components/atoms/Head' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' -import BattlesuitSmallIcon from '../../../../components/v2/BattlesuitSmallIcon' -import { BattlesuitCatalogItem, ErSupportBattlesuit } from '../../../../lib/v2/data/types' -import { loadBattlesuitCatalog, loadErSupports } from '../../../../lib/v2/server/loadData' -import { getI18NProps } from '../../../../server/i18n' +import Head from '../../../components/atoms/Head' +import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' +import Breadcrumb from '../../../components/organisms/Breadcrumb' +import BattlesuitSmallIcon from '../../../components/v2/BattlesuitSmallIcon' +import { BattlesuitCatalogItem, ErSupportBattlesuit } from '../../../lib/v2/data/types' +import { loadBattlesuitCatalog, loadErSupports } from '../../../lib/v2/server/loadData' +import { getI18NProps } from '../../../server/i18n' interface SupportsPageProps { battlesuitCatalog: BattlesuitCatalogItem[] diff --git a/src/pages/honkai3rd/v2/stigmata-sets/[stigmataSetId].tsx b/src/pages/honkai3rd/stigmata-sets/[stigmataSetId].tsx similarity index 91% rename from src/pages/honkai3rd/v2/stigmata-sets/[stigmataSetId].tsx rename to src/pages/honkai3rd/stigmata-sets/[stigmataSetId].tsx index 151dbd82..f9227c7d 100644 --- a/src/pages/honkai3rd/v2/stigmata-sets/[stigmataSetId].tsx +++ b/src/pages/honkai3rd/stigmata-sets/[stigmataSetId].tsx @@ -1,17 +1,17 @@ import { NextPageContext } from 'next' import { Box, Card, Flex, Heading, Link } from 'theme-ui' -import FormattedText from '../../../../components/v2/FormattedText' -import { formatSubSkillInfo } from '../../../../lib/v2/data/formatText' -import { loadStigmaData, loadStigmataSetCatalog, loadStigmataSetData } from '../../../../lib/v2/server/loadData' -import { RootStigma, StigmataSet } from '../../../../lib/v2/data/types' +import FormattedText from '../../../components/v2/FormattedText' +import { formatSubSkillInfo } from '../../../lib/v2/data/formatText' +import { loadStigmaData, loadStigmataSetCatalog, loadStigmataSetData } from '../../../lib/v2/server/loadData' +import { RootStigma, StigmataSet } from '../../../lib/v2/data/types' import { Fragment } from 'react' -import StigmaIcon from '../../../../components/v2/StigmaIcon' -import StigmaFigureImage from '../../../../components/v2/StigmaFigureImage' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import Head from '../../../../components/atoms/Head' +import StigmaIcon from '../../../components/v2/StigmaIcon' +import StigmaFigureImage from '../../../components/v2/StigmaFigureImage' +import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' +import Head from '../../../components/atoms/Head' import { useTranslation } from 'next-i18next' -import { getI18NProps } from '../../../../server/i18n' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' +import { getI18NProps } from '../../../server/i18n' +import Breadcrumb from '../../../components/organisms/Breadcrumb' interface StigmataSetShowPage { stigmataSet: StigmataSet diff --git a/src/pages/honkai3rd/v2/stigmata-sets/index.tsx b/src/pages/honkai3rd/stigmata-sets/index.tsx similarity index 86% rename from src/pages/honkai3rd/v2/stigmata-sets/index.tsx rename to src/pages/honkai3rd/stigmata-sets/index.tsx index c7f8d5b0..a6f5192f 100644 --- a/src/pages/honkai3rd/v2/stigmata-sets/index.tsx +++ b/src/pages/honkai3rd/stigmata-sets/index.tsx @@ -3,14 +3,14 @@ import { Box, Card, Heading } from '@theme-ui/components' import { NextPageContext } from 'next' import { Flex, Link } from 'theme-ui' -import { StigmataSetCatalogItem } from '../../../../lib/v2/data/types' -import { loadStigmataSetCatalog } from '../../../../lib/v2/server/loadData' -import StigmaIcon from '../../../../components/v2/StigmaIcon' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import Head from '../../../../components/atoms/Head' +import { StigmataSetCatalogItem } from '../../../lib/v2/data/types' +import { loadStigmataSetCatalog } from '../../../lib/v2/server/loadData' +import StigmaIcon from '../../../components/v2/StigmaIcon' +import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' +import Head from '../../../components/atoms/Head' import { useTranslation } from 'next-i18next' -import { getI18NProps } from '../../../../server/i18n' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' +import { getI18NProps } from '../../../server/i18n' +import Breadcrumb from '../../../components/organisms/Breadcrumb' interface StigmataSetListPageProps { stigmataSetCatalog: StigmataSetCatalogItem[] diff --git a/src/pages/honkai3rd/v2/stigmata/[stigmaId].tsx b/src/pages/honkai3rd/stigmata/[stigmaId].tsx similarity index 88% rename from src/pages/honkai3rd/v2/stigmata/[stigmaId].tsx rename to src/pages/honkai3rd/stigmata/[stigmaId].tsx index 07a7e1b1..12c40246 100644 --- a/src/pages/honkai3rd/v2/stigmata/[stigmaId].tsx +++ b/src/pages/honkai3rd/stigmata/[stigmaId].tsx @@ -1,19 +1,19 @@ import { NextPageContext } from 'next' import { Box, Card, Flex, Heading, Link } from 'theme-ui' -import FormattedText from '../../../../components/v2/FormattedText' -import { formatSubSkillInfo, replaceNewLine } from '../../../../lib/v2/data/formatText' -import { loadStigmaData, loadStigmataCatalog, loadStigmataSetData } from '../../../../lib/v2/server/loadData' -import { RootStigma, StigmataSetCatalogItem } from '../../../../lib/v2/data/types' +import FormattedText from '../../../components/v2/FormattedText' +import { formatSubSkillInfo, replaceNewLine } from '../../../lib/v2/data/formatText' +import { loadStigmaData, loadStigmataCatalog, loadStigmataSetData } from '../../../lib/v2/server/loadData' +import { RootStigma, StigmataSetCatalogItem } from '../../../lib/v2/data/types' import { Fragment } from 'react' -import { getStigmaTypeLabel } from '../../../../lib/v2/data/text' -import StigmaTypeIcon from '../../../../components/v2/StigmaTypeIcon' -import StigmaIcon from '../../../../components/v2/StigmaIcon' -import StigmaFigureImage from '../../../../components/v2/StigmaFigureImage' -import { getI18NProps } from '../../../../server/i18n' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import Head from '../../../../components/atoms/Head' +import { getStigmaTypeLabel } from '../../../lib/v2/data/text' +import StigmaTypeIcon from '../../../components/v2/StigmaTypeIcon' +import StigmaIcon from '../../../components/v2/StigmaIcon' +import StigmaFigureImage from '../../../components/v2/StigmaFigureImage' +import { getI18NProps } from '../../../server/i18n' +import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' +import Head from '../../../components/atoms/Head' import { useTranslation } from 'next-i18next' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' +import Breadcrumb from '../../../components/organisms/Breadcrumb' interface StigmaShowPageProps { rootStigma: RootStigma diff --git a/src/pages/honkai3rd/stigmata/[stigmataId].tsx b/src/pages/honkai3rd/stigmata/[stigmataId].tsx deleted file mode 100644 index 7ac86a45..00000000 --- a/src/pages/honkai3rd/stigmata/[stigmataId].tsx +++ /dev/null @@ -1,80 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { NextPageContext } from 'next' -import SingleStigmataPage, { - SingleStigmataPageProps, -} from '../../../components/pages/SingleStigmataPage' -import StigmataSetPage, { - StigmataSetProps, -} from '../../../components/pages/StigmataSetPage' -import { generateI18NPaths, getI18NProps } from '../../../server/i18n' -import { - listStigmata, - getStigmaById, - getStigmataListBySetId, - getStigmataSetBySetId, - listStigmataSet, -} from '../../../server/data/honkai3rd/stigmata' - -type StigmataShowPageProps = SingleStigmataPageProps | StigmataSetProps - -const StigmataListPage = (props: StigmataShowPageProps) => { - if (props.type === 'single') { - return - } - - return -} - -export default StigmataListPage - -export async function getStaticProps({ - params, - locale, -}: NextPageContext & { params: { stigmataId: string } }) { - const stigmataData = getStigmaById(params.stigmataId, locale)! - if (stigmataData != null) { - return { - props: { - type: 'single', - stigmataData: stigmataData, - stigmataSetList: ( - (stigmataData.set != null && - getStigmataListBySetId(stigmataData.set!, locale)) || - [] - ).sort((a, b) => -a.type.localeCompare(b.type)), - stigmataSet: getStigmataSetBySetId(stigmataData.set!, locale) || null, - ...(await getI18NProps(locale)), - }, - } - } - const [stigmataSetId] = params.stigmataId.split('-set') - const stigmataSet = getStigmataSetBySetId(stigmataSetId, locale)! - return { - props: { - type: 'set', - stigmataSet, - stigmataSetList: ( - getStigmataListBySetId(stigmataSet.id, locale) || [] - ).sort((a, b) => -a.type.localeCompare(b.type)), - ...(await getI18NProps(locale)), - }, - } -} - -export async function getStaticPaths() { - return { - paths: generateI18NPaths([ - ...listStigmata().map((stigmata) => { - return { - params: { stigmataId: stigmata.id }, - } - }), - ...listStigmataSet().map((stigmataSet) => { - return { - params: { stigmataId: `${stigmataSet.id}-set` }, - } - }), - ]), - fallback: false, - } -} diff --git a/src/pages/honkai3rd/stigmata/index.tsx b/src/pages/honkai3rd/stigmata/index.tsx index 5ce04331..0003682f 100644 --- a/src/pages/honkai3rd/stigmata/index.tsx +++ b/src/pages/honkai3rd/stigmata/index.tsx @@ -1,97 +1,54 @@ /** @jsxImportSource theme-ui */ -import { Box, Heading, Flex } from '@theme-ui/components' +import { Box, Card, Heading } from '@theme-ui/components' import { NextPageContext } from 'next' -import { useRouter } from 'next/router' -import { pick } from 'ramda' -import { useMemo } from 'react' -import PageLink from '../../../components/atoms/PageLink' -import StigmataCard from '../../../components/molecules/StigmataCard' -import StigmataSetCard from '../../../components/molecules/StigmataSetCard' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import { StigmataData, StigmataSet } from '../../../lib/honkai3rd/stigmata' -import { getI18NProps } from '../../../server/i18n' -import { - listStigmata, - listStigmataSet, -} from '../../../server/data/honkai3rd/stigmata' -import { useTranslation } from 'next-i18next' -import Head from '../../../components/atoms/Head' +import { Flex, Link } from 'theme-ui' + +import { StigmataCatalogItem } from '../../../lib/v2/data/types' +import { loadStigmataCatalog } from '../../../lib/v2/server/loadData' +import StigmaIcon from '../../../components/v2/StigmaIcon' import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' +import { getI18NProps } from '../../../server/i18n' interface StigmataListPageProps { - stigmataDataList: Pick[] - stigmataSetList: Pick[] + stigmataCatalog: StigmataCatalogItem[] } -const StigmataListPage = ({ - stigmataDataList, - stigmataSetList, -}: StigmataListPageProps) => { - const { t } = useTranslation() - const { query } = useRouter() - - const listMode = useMemo(() => { - if (query.list == null) { - return 'set' - } - return typeof query.list === 'string' ? query.list : query.list[0] - }, [query]) - +const StigmataListPage = ({ stigmataCatalog }: StigmataListPageProps) => { return ( - + + Stigmata (Single) - - - - {t('stigmata-list.stigmata')} - - - - {t('stigmata-list.set-list')} - - - - - {listMode === 'set' - ? stigmataSetList.map((stigmataSet) => { - return ( - - ) - }) - : stigmataDataList.map((stigmata) => { - return - })} + + {stigmataCatalog + .filter(filterStigmata) + .sort(sortStigmata) + .map(stigma => { + return ( + + + + + + + + {stigma.name} + + {/* {stigma.id} */} + + + + ) + })} @@ -101,15 +58,21 @@ const StigmataListPage = ({ export default StigmataListPage export async function getStaticProps({ locale }: NextPageContext) { + const stigmataCatalog = loadStigmataCatalog() + return { - props: { - stigmataDataList: listStigmata(locale).map((stigmata) => - pick(['id', 'name', 'rarity'], stigmata) - ), - stigmataSetList: listStigmataSet(locale).map((stigmataSet) => - pick(['id', 'name', 'rarity'], stigmataSet) - ), - ...(await getI18NProps(locale)), - }, + props: { stigmataCatalog, ...(await getI18NProps(locale)) } } } + +function filterStigmata(weapon: StigmataCatalogItem) { + return true +} + +function sortStigmata(a: StigmataCatalogItem, b: StigmataCatalogItem) { + let aId = parseInt(a.id) + + let bId = parseInt(b.id) + + return bId - aId +} diff --git a/src/pages/honkai3rd/temp/enemies.tsx b/src/pages/honkai3rd/temp/enemies.tsx deleted file mode 100644 index 95455097..00000000 --- a/src/pages/honkai3rd/temp/enemies.tsx +++ /dev/null @@ -1,49 +0,0 @@ -/* eslint-disable jsx-a11y/alt-text */ -import { times } from 'ramda' - -interface BossSearchPageProps {} - -// const AZArray = times((index) => { -// const charCode = 'A'.charCodeAt(0) + index -// const result = String.fromCharCode(charCode) -// return result -// }, 26) -const NumberArray = times((index) => { - if (index / 100 >= 1) { - return index - } - if (index / 10 >= 1) { - return '0' + index - } - return '00' + index -}, 1000) - -const BossSearchPage = ({}: BossSearchPageProps) => { - return NumberArray.map((item) => { - return ( - - ) - }) - // return AZArray.reduce((array, firstChar) => { - // return [ - // ...array, - // ...AZArray.map((secondChar) => firstChar + secondChar + '_110.png'), - // ] - // }, []).map((item) => { - // return ( - // - // ) - // }) -} - -export default BossSearchPage - -// PSY : UL -// MECHA : RO -// BIO : DG diff --git a/src/pages/honkai3rd/temp/prints/battlesuits/[battlesuitId].tsx b/src/pages/honkai3rd/temp/prints/battlesuits/[battlesuitId].tsx deleted file mode 100644 index 448ae3bb..00000000 --- a/src/pages/honkai3rd/temp/prints/battlesuits/[battlesuitId].tsx +++ /dev/null @@ -1,328 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { - Box, - Card, - Flex, - Heading, - Paragraph, - Text, - Image, -} from '@theme-ui/components' -import { NextPageContext } from 'next' -import React from 'react' -import BattlesuitFeatureLabel from '../../../../../components/atoms/BattlesuitFeatureLabel' -import BattlesuitRankIcon from '../../../../../components/atoms/BattlesuitRankIcon' -import PageLink from '../../../../../components/atoms/PageLink' -import SecondaryLabel from '../../../../../components/atoms/SecondaryLabel' -import TypeLabel from '../../../../../components/atoms/TypeLabel' -import ValkyrieLabel from '../../../../../components/atoms/ValkyrieLabel' -import { - BattlesuitData, - BattlesuitSkillGroup, -} from '../../../../../lib/honkai3rd/battlesuits' -import { generateI18NPaths, getI18NProps } from '../../../../../server/i18n' -import { - getBattlesuitById, - listBattlesuits, -} from '../../../../../server/data/honkai3rd/battlesuits' -import { useTranslation } from '../../../../../lib/i18n' -import { assetsBucketBaseUrl } from '../../../../../lib/consts' -import { WeaponData } from '../../../../../lib/honkai3rd/weapons' -import { getWeaponMapByIds } from '../../../../../server/data/honkai3rd/weapons' -import { StigmataData } from '../../../../../lib/honkai3rd/stigmata' -import WeaponCard from '../../../../../components/molecules/WeaponCard' -import StigmataCard from '../../../../../components/molecules/StigmataCard' -import { getStigmataMapByIds } from '../../../../../server/data/honkai3rd/stigmata' - -type WeaponObjectMap = { [key: string]: WeaponData } -type StigmataObjectMap = { [key: string]: StigmataData } - -interface BattlesuitShowPageProps { - battlesuit: BattlesuitData - weaponMap: WeaponObjectMap - stigmataMap: StigmataObjectMap -} - -const BattlesuitShowPage = ({ - battlesuit, - weaponMap, - stigmataMap, -}: BattlesuitShowPageProps) => { - const { t } = useTranslation() - - return ( - - {battlesuit.name} - - - - {battlesuit.name} - - - - - - - - - - - - - - - - {battlesuit.features.map((feature) => { - return ( - - - - - - ) - })} - - - - {battlesuit.equipment != null && ( - - {battlesuit.equipment.map((equipmentItem) => { - return ( - - - {t(`battlesuit-show.equipmentTypes.${equipmentItem.type}`)} - - - {equipmentItem.weapon != null && ( - - )} - {equipmentItem.stigmataTop != null && ( - - )} - {equipmentItem.stigmataMid != null && ( - - )} - {equipmentItem.stigmataBot != null && ( - - )} - - - ) - })} - - )} - - - - - - - - - - - - - - {battlesuit.sp != null && ( - - )} - - ) -} - -export default BattlesuitShowPage - -export async function getStaticProps({ - params, - locale, -}: NextPageContext & { params: { battlesuitId: string } }) { - const battlesuit = getBattlesuitById(params.battlesuitId, locale)! - const { weaponIds, stigmataIds } = (battlesuit.equipment || []).reduce<{ - weaponIds: string[] - stigmataIds: string[] - }>( - (acc, equipmentItem) => { - acc.weaponIds.push(equipmentItem.weapon) - acc.stigmataIds.push( - equipmentItem.stigmataTop, - equipmentItem.stigmataMid, - equipmentItem.stigmataBot - ) - return acc - }, - { weaponIds: [], stigmataIds: [] } - ) - const weaponMap = getWeaponMapByIds(weaponIds, locale) - - const stigmataMap = getStigmataMapByIds(stigmataIds, locale) - - return { - props: { - battlesuit, - weaponMap, - stigmataMap, - ...(await getI18NProps(locale)), - }, - } -} - -export async function getStaticPaths() { - return { - paths: generateI18NPaths( - listBattlesuits().map((battlesuit) => { - return { - params: { battlesuitId: battlesuit.id }, - } - }) - ), - fallback: false, - } -} - -interface BattlesuitSkillGroupCardProps { - heading: string - skillGroup: BattlesuitSkillGroup -} - -const BattlesuitSkillGroupCard = ({ - heading, - skillGroup, -}: BattlesuitSkillGroupCardProps) => { - return ( - - - - {skillGroup.core.name} - - {heading} - - - - {skillGroup.core.description} - - - {skillGroup.subskills.map((subskill) => { - return ( - - - - {subskill.name} - {subskill.requiredRank != null ? ( - /^[0-9]/.test(subskill.requiredRank) ? ( - - ⭐{subskill.requiredRank.slice(0, 1)} - - ) : ( - - ) - ) : ( - - )} - - - - - {subskill.description} - - - ) - })} - - ) -} diff --git a/src/pages/honkai3rd/temp/prints/stigmata/[stigmataId].tsx b/src/pages/honkai3rd/temp/prints/stigmata/[stigmataId].tsx deleted file mode 100644 index 660fb93f..00000000 --- a/src/pages/honkai3rd/temp/prints/stigmata/[stigmataId].tsx +++ /dev/null @@ -1,158 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { NextPageContext } from 'next' -import React from 'react' -import PageLink from '../../../../../components/atoms/PageLink' -import { StigmataSetProps } from '../../../../../components/pages/StigmataSetPage' -import { generateI18NPaths, getI18NProps } from '../../../../../server/i18n' -import { - listStigmata, - getStigmataListBySetId, - getStigmataSetBySetId, - listStigmataSet, - getStigmaById, -} from '../../../../../server/data/honkai3rd/stigmata' -import { Box, Card, Flex, Heading, Paragraph } from 'theme-ui' -import SecondaryLabel from '../../../../../components/atoms/SecondaryLabel' -import StigmataCard from '../../../../../components/molecules/StigmataCard' -import { useTranslation } from '../../../../../lib/i18n' -import { SingleStigmataPageProps } from '../../../../../components/pages/SingleStigmataPage' - -type StigmataShowPageProps = StigmataSetProps | SingleStigmataPageProps - -const StigmataListPage = (props: StigmataShowPageProps) => { - const { t } = useTranslation() - - if (props.type === 'single') { - return null - } - - const { stigmataSet, stigmataSetList } = props - - return ( - - - - {stigmataSet.name} - - {stigmataSet.altName} - - - - - {stigmataSetList.map((stigmataSetItem) => { - return ( - - ) - })} - - {stigmataSetList.map((stigmataSetItem) => { - return ( - - - - - {stigmataSetItem.name} - - - - {t(`stigmata-show.${stigmataSetItem.type}`)} - - - - HP : {stigmataSetItem.hp} / ATK : {stigmataSetItem.atk} / DEF :{' '} - {stigmataSetItem.def} / CRT : {stigmataSetItem.crt} - - - {stigmataSetItem.skill.description} - - - ) - })} - - - - - {stigmataSet.twoSetSkill.name} - - - {stigmataSet.twoSetSkill.description} - - - {stigmataSet.threeSetSkill.name} - - - {stigmataSet.threeSetSkill.description} - - - - ) -} - -export default StigmataListPage - -export async function getStaticProps({ - params, - locale, -}: NextPageContext & { params: { stigmataId: string } }) { - const stigmataData = getStigmaById(params.stigmataId, locale)! - if (stigmataData != null) { - return { - props: { - type: 'single', - stigmataData: stigmataData, - stigmataSetList: ( - getStigmataListBySetId(stigmataData.set!, locale) || [] - ).sort((a, b) => -a.type.localeCompare(b.type)), - stigmataSet: getStigmataSetBySetId(stigmataData.set!, locale) || null, - ...(await getI18NProps(locale)), - }, - } - } - const [stigmataSetId] = params.stigmataId.split('-set') - const stigmataSet = getStigmataSetBySetId(stigmataSetId, locale)! - return { - props: { - type: 'set', - stigmataSet, - stigmataSetList: ( - getStigmataListBySetId(stigmataSet.id, locale) || [] - ).sort((a, b) => -a.type.localeCompare(b.type)), - ...(await getI18NProps(locale)), - }, - } -} - -export async function getStaticPaths() { - return { - paths: generateI18NPaths([ - ...listStigmata().map((stigmata) => { - return { - params: { stigmataId: stigmata.id }, - } - }), - ...listStigmataSet().map((stigmataSet) => { - return { - params: { stigmataId: `${stigmataSet.id}-set` }, - } - }), - ]), - fallback: false, - } -} diff --git a/src/pages/honkai3rd/temp/prints/weapons/[weaponId].tsx b/src/pages/honkai3rd/temp/prints/weapons/[weaponId].tsx deleted file mode 100644 index 588cdf86..00000000 --- a/src/pages/honkai3rd/temp/prints/weapons/[weaponId].tsx +++ /dev/null @@ -1,195 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Flex, Box, Card, Heading, Paragraph } from '@theme-ui/components' -import { NextPageContext } from 'next' -import SquareImageBox from '../../../../../components/atoms/SquareImageBox' -import { - weaponCategories, - WeaponData, -} from '../../../../../lib/honkai3rd/weapons' -import { generateI18NPaths, getI18NProps } from '../../../../../server/i18n' -import { - getWeaponById, - getWeaponMapByIds, - listWeapons, -} from '../../../../../server/data/honkai3rd/weapons' -import { useTranslation } from '../../../../../lib/i18n' -import PageLink from '../../../../../components/atoms/PageLink' -import { assetsBucketBaseUrl } from '../../../../../lib/consts' -import { getBattlesuitMapByIds } from '../../../../../server/data/honkai3rd/battlesuits' -import { BattlesuitData } from '../../../../../lib/honkai3rd/battlesuits' -import BattlesuitCard from '../../../../../components/molecules/BattlesuitCard' -import WeaponCard from '../../../../../components/molecules/WeaponCard' - -interface WeaponShowPageProps { - weapon: WeaponData - battlesuitMap: { [key: string]: BattlesuitData } - weaponMap: { [key: string]: WeaponData } -} - -const WeaponShowPage = ({ - weapon, - battlesuitMap, - weaponMap, -}: WeaponShowPageProps) => { - const { t } = useTranslation() - - const weaponCategoryName = t(`weapons-show.${weapon.category}`) - const weaponCategory = weaponCategories.find( - (category) => category.value === weapon.category - ) - - return ( - - {weapon.name} - - - - - - - - - - {weaponCategory != null && ( - - )} - {weaponCategoryName} - - - - - {'⭐'.repeat(weapon.rarity)} - - - ATK : {weapon.atk} / CRT : {weapon.crt} - - {weapon.battlesuits != null && weapon.battlesuits.length > 0 && ( - - {t('weapons-show.best-on')} - {weapon.battlesuits.map(({ id: battlesuitId }) => { - return ( - - ) - })} - - )} - {weapon.priWeapon != null && ( - - {t('weapons-show.pri-weapon')} - - - )} - {weapon.originalWeapons != null && weapon.originalWeapons.length > 0 && ( - - {t('weapons-show.original-weapon')} - {weapon.originalWeapons.map((originalWeaponId) => { - return ( - - ) - })} - - )} - {/* {weapon.sources != null && ( - - {t('weapons-show.sources')} - {weapon.sources - .sort((a, b) => a.type.localeCompare(b.type)) - .map((source) => { - return - })} - - )} */} - - - - {weapon.skills.map((skill) => { - return ( - - - {skill.name} - - - {skill.description} - - - ) - })} - - - ) -} - -export default WeaponShowPage - -export async function getStaticProps({ - params, - locale, -}: NextPageContext & { params: { weaponId: string } }) { - const weapon = getWeaponById(params.weaponId, locale) - const battlesuitMap = getBattlesuitMapByIds( - weapon != null && weapon.battlesuits != null - ? weapon.battlesuits.map(({ id }) => id) - : [], - locale - ) - - const weaponIds = [] - if (weapon != null) { - if (weapon.priWeapon != null) { - weaponIds.push(weapon.priWeapon) - } - if (weapon.originalWeapons != null) { - weaponIds.push(...weapon.originalWeapons) - } - } - const weaponMap = getWeaponMapByIds(weaponIds, locale) - - return { - props: { - weapon, - battlesuitMap, - weaponMap, - ...(await getI18NProps(locale)), - }, - } -} - -export async function getStaticPaths() { - return { - paths: generateI18NPaths( - listWeapons().map((weapon) => { - return { - params: { weaponId: weapon.id }, - } - }) - ), - fallback: false, - } -} diff --git a/src/pages/honkai3rd/v2/battlesuits/[battlesuitId].tsx b/src/pages/honkai3rd/v2/battlesuits/[battlesuitId].tsx deleted file mode 100644 index d5e072ca..00000000 --- a/src/pages/honkai3rd/v2/battlesuits/[battlesuitId].tsx +++ /dev/null @@ -1,194 +0,0 @@ -import { NextPageContext } from 'next' -import { Box, Card, Flex, Heading } from 'theme-ui' -import AttributeIcon from '../../../../components/v2/AttributeIcon' -import AvatarFigureImage from '../../../../components/v2/AvatarFigureImage' -import AvatarSkillIcon from '../../../../components/v2/AvatarSkillIcon' -import AvatarSubSkillIcon from '../../../../components/v2/AvatarSubSkillIcon' -import BattlesuitAvatarIcon from '../../../../components/v2/BattlesuitAvatarIcon' -import FormattedText from '../../../../components/v2/FormattedText' -import { formatSkillInfo, formatSubSkillInfo } from '../../../../lib/v2/data/formatText' -import { loadBattlesuitCatalog, loadBattlesuitData } from '../../../../lib/v2/server/loadData' -import { Battlesuit, SkillTagItem } from '../../../../lib/v2/data/types' -import { Fragment } from 'react' -import TagIcon from '../../../../components/v2/TagIcon' -import { - getAttributeLabel, - getCharacterTypeLabel, - getSkillTypeLabel, - getTagTypeLabel, - getWeaponTypeLabel -} from '../../../../lib/v2/data/text' -import StarIcon from '../../../../components/v2/StarIcon' -import ChibiIcon from '../../../../components/v2/ChibiIcon' -import WeaponTypeIcon from '../../../../components/v2/WeaponTypeIcon' -import { sortBattlesuitSkill } from '../../../../lib/v2/data/utils' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import { getI18NProps } from '../../../../server/i18n' -import Head from '../../../../components/atoms/Head' -import { useTranslation } from 'next-i18next' - -interface BattlesuitShowPageProps { - battlesuit: Battlesuit -} - -const BattlesuitShowPage = ({ battlesuit }: BattlesuitShowPageProps) => { - const { t } = useTranslation() - return ( - - { - return getTagTypeLabel(tag) - }) - .join(', ')}`} - canonicalHref={`/honkai3rd/battlesuits/${battlesuit.id}`} - /> - - {battlesuit.fullName} - - - - - - - - - - - - - - - - - - {getCharacterTypeLabel(battlesuit.character)} - - - - - {getAttributeLabel(battlesuit.attributeType)} - - - - {getWeaponTypeLabel(battlesuit.weapon)} - - - - {battlesuit.tags.map(tag => { - return ( - - - {getTagTypeLabel(tag)} - - ) - })} - - - - Skills - {battlesuit.skills.sort(sortBattlesuitSkill).map(skill => { - return ( - - - - - - {skill.name} - - {skill.tags.length > 0 && ( - - {skill.tags.map((tag, index) => { - return - })} - - )} - - - {getSkillTypeLabel(skill.skillType)} - - - {formatSkillInfo(skill)} - - - {skill.subSkills.map(subSkill => { - return ( - - - - - - {subSkill.name} - - - {subSkill.unlockStar.localeCompare(battlesuit.initialStar) > 0 && ( - - - - )} - - {subSkill.tags.length > 0 && ( - - {subSkill.tags.map((tag, index) => { - return - })} - - )} - - - - - {formatSubSkillInfo(subSkill)} - - - ) - })} - - ) - })} - {/*
{JSON.stringify(battlesuit, null, 2)}
*/} -
-
- ) -} - -export default BattlesuitShowPage - -export async function getStaticProps({ locale, params }: NextPageContext & { params: { battlesuitId: string } }) { - const battlesuit = loadBattlesuitData(params.battlesuitId) - - return { - props: { battlesuit, ...(await getI18NProps(locale)) } - } -} - -export async function getStaticPaths() { - const battlesuitCatalog = loadBattlesuitCatalog() - - return { - paths: battlesuitCatalog.map(catalogItem => { - return { - params: { battlesuitId: catalogItem.id } - } - }), - fallback: false - } -} - -interface SkillTagBoxProps { - tag: SkillTagItem -} - -const SkillTagItem = ({ tag }: SkillTagBoxProps) => { - return -} diff --git a/src/pages/honkai3rd/v2/battlesuits/index.tsx b/src/pages/honkai3rd/v2/battlesuits/index.tsx deleted file mode 100644 index 42f4cbf7..00000000 --- a/src/pages/honkai3rd/v2/battlesuits/index.tsx +++ /dev/null @@ -1,62 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box } from '@theme-ui/components' -import { NextPageContext } from 'next' -import { Flex, Link } from 'theme-ui' -import { loadBattlesuitCatalog } from '../../../../lib/v2/server/loadData' -import { BattlesuitCatalogItem } from '../../../../lib/v2/data/types' -import BattlesuitCatalogItemCard from '../../../../components/v2/BattlesuitCatalogItemCard' -import Head from '../../../../components/atoms/Head' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import { useTranslation } from 'next-i18next' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' -import { getI18NProps } from '../../../../server/i18n' - -interface BattlesuitListPageProps { - battlesuitCatalog: BattlesuitCatalogItem[] -} - -const BattlesuitListPage = ({ battlesuitCatalog }: BattlesuitListPageProps) => { - const { t } = useTranslation() - return ( - - - - -

{t('battlesuits-list.heading')}

- - {battlesuitCatalog.map(battlesuit => { - return ( - - - - - - ) - })} - -
-
- ) -} - -export default BattlesuitListPage - -export async function getStaticProps({ locale }: NextPageContext) { - const battlesuitCatalog = loadBattlesuitCatalog() - - return { - props: { battlesuitCatalog, ...(await getI18NProps(locale)) } - } -} diff --git a/src/pages/honkai3rd/v2/elfs/[elfId].tsx b/src/pages/honkai3rd/v2/elfs/[elfId].tsx deleted file mode 100644 index 458299b4..00000000 --- a/src/pages/honkai3rd/v2/elfs/[elfId].tsx +++ /dev/null @@ -1,117 +0,0 @@ -import { NextPageContext } from 'next' -import { Box, Card, Flex, Heading } from 'theme-ui' -import { useMemo } from 'react' -import { Elf, ElfSkill } from '../../../../lib/v2/data/types' -import { loadElfCatalog, loadElfData } from '../../../../lib/v2/server/loadData' -import SquareImage from '../../../../components/v2/SquareImage' -import TagIcon from '../../../../components/v2/TagIcon' -import { assetsBucketBaseUrl } from '../../../../lib/consts' -import { ListMap } from '../../../../lib/utils' -import FormattedText from '../../../../components/v2/FormattedText' -import { formatSubSkillInfo } from '../../../../lib/v2/data/formatText' - -interface ElfShowPageProps { - elf: Elf -} - -const ElfShowPage = ({ elf }: ElfShowPageProps) => { - const skillRows = useMemo(() => { - const rowSkillListMap = elf.skills.reduce>((map, skill) => { - map.set(skill.row.toString(), skill) - return map - }, new ListMap()) - - return [...rowSkillListMap.values()] - }, [elf.skills]) - return ( - - {elf.fullName} - - - - - - {elf.tags.map(tag => { - return ( - - - - ) - })} - - - - Ult CD: {elf.ultSkillCd} / Ult SP Cost: {elf.ultSkillCost} - - - - Skills - - {skillRows.map((row, index) => { - return ( - - {row.map(skill => { - return ( - - - - - - - - {skill.name} - - {/* {skill.id} */} - ({skill.skillType}) - - - - {formatSubSkillInfo(skill)} - - - ) - })} - - ) - })} - - ) -} - -export default ElfShowPage - -export async function getStaticProps({ locale, params }: NextPageContext & { params: { elfId: string } }) { - const elf = loadElfData(params.elfId) - - return { - props: { elf } - } -} - -export async function getStaticPaths() { - const elfCatalog = loadElfCatalog() - - return { - paths: elfCatalog.map(catalogItem => { - return { - params: { elfId: catalogItem.id } - } - }), - fallback: false - } -} diff --git a/src/pages/honkai3rd/v2/elfs/index.tsx b/src/pages/honkai3rd/v2/elfs/index.tsx deleted file mode 100644 index d47398a7..00000000 --- a/src/pages/honkai3rd/v2/elfs/index.tsx +++ /dev/null @@ -1,61 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box, Card } from '@theme-ui/components' -import { NextPageContext } from 'next' -import { Flex, Link } from 'theme-ui' -import { ElfCatalogItem } from '../../../../lib/v2/data/types' -import { loadElfCatalog } from '../../../../lib/v2/server/loadData' -import RarityBar from '../../../../components/v2/RarityBar' -import ElfIcon from '../../../../components/v2/ElfIcon' - -interface ElfListPageProps { - elfs: ElfCatalogItem[] -} - -const ElfListPage = ({ elfs }: ElfListPageProps) => { - return ( - -

Elfs

- - {elfs - .sort((a, b) => { - const aId = getId(a.id) - const bId = getId(b.id) - return bId - aId - - function getId(id: string): number { - return parseInt(id) - } - }) - .map(elf => { - return ( - - - - - - - - - {elf.fullName} - - - - - ) - })} - -
- ) -} - -export default ElfListPage - -export async function getStaticProps({ locale }: NextPageContext) { - const elfs = loadElfCatalog() - - return { - props: { elfs } - } -} diff --git a/src/pages/honkai3rd/v2/index.tsx b/src/pages/honkai3rd/v2/index.tsx deleted file mode 100644 index ef76a851..00000000 --- a/src/pages/honkai3rd/v2/index.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import Link from 'next/link' -import { Box } from 'theme-ui' - -const HomePage = () => { - return ( -
-

V2 Pre

- - Battlesuits - - - Weapons - - - Stigmata - - - StigmataSets - - - Elfs - - - Elysian Realm - -
- ) -} - -export default HomePage diff --git a/src/pages/honkai3rd/v2/stigmata/index.tsx b/src/pages/honkai3rd/v2/stigmata/index.tsx deleted file mode 100644 index 3ae1f349..00000000 --- a/src/pages/honkai3rd/v2/stigmata/index.tsx +++ /dev/null @@ -1,78 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box, Card, Heading } from '@theme-ui/components' -import { NextPageContext } from 'next' -import { Flex, Link } from 'theme-ui' - -import { StigmataCatalogItem } from '../../../../lib/v2/data/types' -import { loadStigmataCatalog } from '../../../../lib/v2/server/loadData' -import StigmaIcon from '../../../../components/v2/StigmaIcon' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import { getI18NProps } from '../../../../server/i18n' - -interface StigmataListPageProps { - stigmataCatalog: StigmataCatalogItem[] -} - -const StigmataListPage = ({ stigmataCatalog }: StigmataListPageProps) => { - return ( - - - Stigmata (Single) - - - {stigmataCatalog - .filter(filterStigmata) - .sort(sortStigmata) - .map(stigma => { - return ( - - - - - - - - {stigma.name} - - {/* {stigma.id} */} - - - - ) - })} - - - - ) -} - -export default StigmataListPage - -export async function getStaticProps({ locale }: NextPageContext) { - const stigmataCatalog = loadStigmataCatalog() - - return { - props: { stigmataCatalog, ...(await getI18NProps(locale)) } - } -} - -function filterStigmata(weapon: StigmataCatalogItem) { - return true -} - -function sortStigmata(a: StigmataCatalogItem, b: StigmataCatalogItem) { - let aId = parseInt(a.id) - - let bId = parseInt(b.id) - - return bId - aId -} diff --git a/src/pages/honkai3rd/v2/weapons/[weaponId].tsx b/src/pages/honkai3rd/v2/weapons/[weaponId].tsx deleted file mode 100644 index b9683a1e..00000000 --- a/src/pages/honkai3rd/v2/weapons/[weaponId].tsx +++ /dev/null @@ -1,133 +0,0 @@ -import { NextPageContext } from 'next' -import { Box, Card, Flex, Heading } from 'theme-ui' -import FormattedText from '../../../../components/v2/FormattedText' -import { formatSubSkillInfo, replaceNewLine } from '../../../../lib/v2/data/formatText' -import { loadWeaponCatalog, loadWeaponData } from '../../../../lib/v2/server/loadData' -import { RootWeaponData } from '../../../../lib/v2/data/types' -import { Fragment } from 'react' -import { getWeaponTypeLabel } from '../../../../lib/v2/data/text' -import WeaponTypeIcon from '../../../../components/v2/WeaponTypeIcon' -import WeaponIcon from '../../../../components/v2/WeaponIcon' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import Head from '../../../../components/atoms/Head' -import { useTranslation } from 'next-i18next' -import { getI18NProps } from '../../../../server/i18n' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' - -interface WeaponShowPageProps { - rootWeapon: RootWeaponData -} - -const WeaponShowPage = ({ rootWeapon }: WeaponShowPageProps) => { - const { t } = useTranslation() - const weapon = rootWeapon.weapons[rootWeapon.weapons.length - 1] - - const weaponTypeLabel = getWeaponTypeLabel(weapon.type) - const atk = Math.floor(weapon.attackBase + weapon.attackAdd * (weapon.maxLv - 1)) - const crt = Math.floor(weapon.criticalBase + weapon.criticalAdd * (weapon.maxLv - 1)) - - return ( - - - - - - {weapon.name} - - - - - - - {replaceNewLine(weapon.description)} - - - {getWeaponTypeLabel(weapon.type)} - - - ATK : {atk} / CRT : {crt} (at Max Lv {weapon.maxLv}) - - - - Skills - - {weapon.skills.map(skill => { - return ( - - - - {skill.name} - - - - - {formatSubSkillInfo({ - info: skill.info, - maxLv: weapon.maxLv, - paramBase1: skill.param1, - paramBase2: skill.param2, - paramBase3: skill.param3, - paramAdd1: skill.param1Add, - paramAdd2: skill.param2Add, - paramAdd3: skill.param3Add - })} - - - - ) - })} - - {/*
{JSON.stringify(weapon, null, 2)}
*/} -
-
- ) -} - -export default WeaponShowPage - -export async function getStaticProps({ locale, params }: NextPageContext & { params: { weaponId: string } }) { - const rootWeapon = loadWeaponData(params.weaponId) - - return { - props: { rootWeapon, ...(await getI18NProps(locale)) } - } -} - -export async function getStaticPaths() { - const weaponCatalog = loadWeaponCatalog() - - return { - paths: weaponCatalog.map(catalogItem => { - return { - params: { weaponId: catalogItem.id } - } - }), - fallback: false - } -} diff --git a/src/pages/honkai3rd/v2/weapons/index.tsx b/src/pages/honkai3rd/v2/weapons/index.tsx deleted file mode 100644 index 6fb926c9..00000000 --- a/src/pages/honkai3rd/v2/weapons/index.tsx +++ /dev/null @@ -1,146 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box, Card } from '@theme-ui/components' -import { NextPageContext } from 'next' -import { Flex, Heading, Link } from 'theme-ui' -import { loadWeaponCatalog } from '../../../../lib/v2/server/loadData' -import { WeaponCatalogItem } from '../../../../lib/v2/data/types' -import WeaponIcon from '../../../../components/v2/WeaponIcon' -import Head from '../../../../components/atoms/Head' -import Honkai3rdLayout from '../../../../components/layouts/Honkai3rdLayout' -import { useTranslation } from 'next-i18next' -import { getI18NProps } from '../../../../server/i18n' -import Breadcrumb from '../../../../components/organisms/Breadcrumb' - -interface WeaponListPageProps { - weaponCatalog: WeaponCatalogItem[] -} - -const WeaponListPage = ({ weaponCatalog }: WeaponListPageProps) => { - const { t } = useTranslation() - return ( - - - - - {t('common.weapons')} - - {weaponCatalog - .filter(filterWeapons) - .sort(sortWeapons) - .map(weapon => { - return ( - - - - - - - - {weapon.name} - - {/* {weapon.id} */} - - - - ) - })} - - - - ) -} - -export default WeaponListPage - -export async function getStaticProps({ locale }: NextPageContext) { - const weaponCatalog = loadWeaponCatalog() - - return { - props: { weaponCatalog, ...(await getI18NProps(locale)) } - } -} - -function filterWeapons(weapon: WeaponCatalogItem) { - // Valid weapons - // 24XXX EX Weapons - // 21XXX Sprit Weapon - // 19XXX Alloy Weapons - // 10XXX Regular Weapons - - // Event Weapon? - if (weapon.id.startsWith('18') && weapon.id.length === 5) { - return false - } - // Test Data? - if (weapon.id.startsWith('1023') && weapon.id.length === 6) { - return false - } - // Unreleased(Number looks good but lacking info) - switch (weapon.id) { - case '24000': // 2nd relic alpha - case '24040': // Removed 7 Thunders - case '24034': // PE Temp Lance - case '24024': // keqing ex - case '20765': // ? - case '10243': // No Name - case '10219': // ? - case '10179': // ? - return false - } - - // Divine Keys - switch (weapon.id) { - case '20000': // Taixuan Sword - case '10248': // Abyss Flower - case '10267': // Eden's star anti entropy - case '10263': // 7 Thunders - case '10247': // Abyss - case '10235': // Fenghuang pistols - case '10234': // Fenghuang fists - case '10223': // Eden twin stars - case '10212': // Pledge of Sakura - case '10211': // Pledge of Judah - case '10209': // Might of an utu - case '10199': // Cleaver of Shamash - case '10163': // Shamash pistols - // The below don't have duplicated data - // case '10180': // Eden's star - // case '10169': // Taxiuan fists - // case '10158': // Jizo Mitama - return false - } - - return true -} - -function sortWeapons(a: WeaponCatalogItem, b: WeaponCatalogItem) { - let aId = parseInt(a.id) - - const aTypeOrder = aId > 21000 && aId < 22000 ? 2 : aId > 19000 && aId < 20000 ? 1 : 0 - - let bId = parseInt(b.id) - const bTypeOrder = bId > 21000 && bId < 22000 ? 2 : bId > 19000 && bId < 20000 ? 1 : 0 - if (aTypeOrder !== bTypeOrder) { - return aTypeOrder - bTypeOrder - } - - return bId - aId -} diff --git a/src/pages/honkai3rd/versions/[versionId].tsx b/src/pages/honkai3rd/versions/[versionId].tsx deleted file mode 100644 index 2c02ae17..00000000 --- a/src/pages/honkai3rd/versions/[versionId].tsx +++ /dev/null @@ -1,264 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box, Heading, Flex, Text, Paragraph } from '@theme-ui/components' -import { NextPageContext } from 'next' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import GanttChart from '../../../components/organisms/GanttChart' -import { - getVersion, - listVersionData, -} from '../../../server/data/honkai3rd/versions' -import { format as formatDate } from 'date-fns' -import { getBattlesuitById } from '../../../server/data/honkai3rd/battlesuits' -import SquareImageBox from '../../../components/atoms/SquareImageBox' -import { getWeaponById } from '../../../server/data/honkai3rd/weapons' -import ScrollContainer from 'react-indiana-drag-scroll' -import { addDateToDateString, getDateString } from '../../../lib/string' -import { BattlesuitData } from '../../../lib/honkai3rd/battlesuits' -import { WeaponData } from '../../../lib/honkai3rd/weapons' -import { VersionData } from '../../../lib/honkai3rd/versions' -import { generateI18NPaths, getI18NProps } from '../../../server/i18n' -import { useTranslation } from '../../../lib/i18n' -import Head from '../../../components/atoms/Head' -import PageLink from '../../../components/atoms/PageLink' -import { assetsBucketBaseUrl } from '../../../lib/consts' -import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' -import { useEffect, useState } from 'react' -import BossTable from '../../../components/organisms/BossTable' -import StigmataSetCard from '../../../components/molecules/StigmataSetCard' -import WeaponCard from '../../../components/molecules/WeaponCard' -import BattlesuitCard from '../../../components/molecules/BattlesuitCard' -import { getStigmataSetBySetId } from '../../../server/data/honkai3rd/stigmata' -import { StigmataSet } from '../../../lib/honkai3rd/stigmata' - -interface VersionShowPageProps { - versionData: VersionData - battlesuits: BattlesuitData[] - weapons: WeaponData[] - stigmataSets: StigmataSet[] -} - -const VersionShowPage = ({ - versionData, - battlesuits, - weapons, - stigmataSets, -}: VersionShowPageProps) => { - const { t } = useTranslation() - const [today, setToday] = useState(null) - useEffect(() => { - setToday(new Date(getDateString(new Date()))) - }, []) - return ( - - { - return battlesuit.name - }) - .join(',')} / ${t('versions.new-weapons')}: ${weapons - .map((weapon) => { - return weapon.name - }) - .join(',')}`} - canonicalHref={`/honkai3rd/versions/${versionData.version}`} - /> - - - - - - {versionData.previousVersion != null && ( - - {t('versions.previous')} (v{versionData.previousVersion}) - - )} - {versionData.nextVersion != null && ( - - {t('versions.next')} (v{versionData.nextVersion}) - - )} - - - v{versionData.version} : {versionData.name} - - - {formatDate(new Date(versionData.duration[0]), 'PP')} -{' '} - {versionData.duration[1] != null - ? formatDate(new Date(versionData.duration[1]), 'PP') - : ''} - - - - - {t('versions.new-battlesuits')} - - - {battlesuits.map((battlesuit) => { - return ( - - ) - })} - - - - {t('versions.new-weapons')} - - - {weapons.map((weapon) => { - return - })} - - - - {t('versions.new-stigmata-sets')} - - - {stigmataSets.map((stigmataSet) => { - return ( - - ) - })} - - - - - {t('versions.weekly-bosses')} - - - - - - - - {t('versions.supply-events')} - - - - { - const imgSrc = getIconSrcFromItem(supplyEventData.featured[0]) - return { - id: `${supplyEventData.duration[0]}/${supplyEventData.duration[1]}/${supplyEventData.name}`, - label: ( - - {!supplyEventData.verified && ( - - )} - {imgSrc != null && ( - - )} - {supplyEventData.name} - - ), - duration: supplyEventData.duration, - row: supplyEventData.track, - } - })} - today={today} - startDate={versionData.duration[0]} - endDate={ - versionData.duration[1] != null - ? versionData.duration[1] - : addDateToDateString(versionData.duration[0], { - weeks: 6, - }) - } - /> - - - {t('versions.supply-events-disclaimer')} - - - - ) -} - -export default VersionShowPage - -export async function getStaticProps({ - params, - locale, -}: NextPageContext & { params: { versionId: string } }) { - const versionData = getVersion(params.versionId, locale)! - - const battlesuits = versionData.newBattlesuits.map((battlesuitId) => { - return getBattlesuitById(battlesuitId, locale) - }) - const weapons = versionData.newWeapons.map((weaponId) => { - return getWeaponById(weaponId, locale) - }) - const stigmataSets = versionData.newStigmataSets.map((stigmataSetId) => { - return getStigmataSetBySetId(stigmataSetId, locale) - }) - - return { - props: { - versionData, - battlesuits, - weapons, - stigmataSets, - ...(await getI18NProps(locale)), - }, - } -} - -export async function getStaticPaths() { - return { - paths: generateI18NPaths( - listVersionData().map((versionData) => { - return { - params: { - versionId: versionData.version.toString(), - }, - } - }) - ), - fallback: false, - } -} - -function getIconSrcFromItem(item: { type: string; id: string }): string | null { - switch (item.type) { - case 'battlesuit': - return `${assetsBucketBaseUrl}/honkai3rd/battlesuits/portrait-${item.id}.png` - case 'weapon': - return `${assetsBucketBaseUrl}/honkai3rd/weapons/${item.id}.png` - case 'stigmata': - return `${assetsBucketBaseUrl}/honkai3rd/stigmata/icon-${item.id}.png` - case 'elf': - return `${assetsBucketBaseUrl}/honkai3rd/elfs/icon-${item.id}.png` - case 'outfit': - return `${assetsBucketBaseUrl}/honkai3rd/outfits/portrait-${item.id}.webp` - } - return null -} diff --git a/src/pages/honkai3rd/versions/index.tsx b/src/pages/honkai3rd/versions/index.tsx deleted file mode 100644 index 53a2795e..00000000 --- a/src/pages/honkai3rd/versions/index.tsx +++ /dev/null @@ -1,86 +0,0 @@ -/** @jsxImportSource theme-ui */ -import { Box, Heading, Link } from '@theme-ui/components' -import NextLink from 'next/link' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import { listVersionData } from '../../../server/data/honkai3rd/versions' -import { format as formatDate } from 'date-fns' -import { BattlesuitData } from '../../../lib/honkai3rd/battlesuits' -import { WeaponData } from '../../../lib/honkai3rd/weapons' -import { VersionData } from '../../../lib/honkai3rd/versions' -import { getI18NProps } from '../../../server/i18n' -import { NextPageContext } from 'next' -import { useTranslation } from '../../../lib/i18n' -import Head from '../../../components/atoms/Head' -import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' -import { StigmataSet } from '../../../lib/honkai3rd/stigmata' - -interface VersionIndexPageProps { - versionDataList: VersionData[] - currentVersionData: VersionData - currentVersionNewBattlesuits: BattlesuitData[] - currentVersionNewWeapons: WeaponData[] - currentVersionNewStigmataSets: StigmataSet[] -} - -const VersionIndexPage = ({ versionDataList }: VersionIndexPageProps) => { - const { t } = useTranslation() - - return ( - - - - - - - - {t('versions.versions')} - - - {versionDataList.map((versionData) => { - return ( - - - - - {versionData.version} : {versionData.name} ( - {formatDate(new Date(versionData.duration[0]), 'PP')} -{' '} - {versionData.duration[1] != null - ? formatDate(new Date(versionData.duration[1]), 'PP') - : ''} - ) - - - - - ) - })} - - - - ) -} - -export async function getStaticProps({ locale }: NextPageContext) { - return { - props: { - versionDataList: listVersionData(locale), - ...(await getI18NProps(locale)), - }, - } -} - -export default VersionIndexPage diff --git a/src/pages/honkai3rd/weapons/[weaponId].tsx b/src/pages/honkai3rd/weapons/[weaponId].tsx index 18a49492..19f7d356 100644 --- a/src/pages/honkai3rd/weapons/[weaponId].tsx +++ b/src/pages/honkai3rd/weapons/[weaponId].tsx @@ -1,32 +1,30 @@ -/** @jsxImportSource theme-ui */ -import { Flex, Box, Card, Heading, Paragraph } from '@theme-ui/components' import { NextPageContext } from 'next' -import SquareImageBox from '../../../components/atoms/SquareImageBox' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import { weaponCategories, WeaponData } from '../../../lib/honkai3rd/weapons' -import { generateI18NPaths, getI18NProps } from '../../../server/i18n' -import { getWeaponById, getWeaponMapByIds, listWeapons } from '../../../server/data/honkai3rd/weapons' -import { useTranslation } from '../../../lib/i18n' -import Head from '../../../components/atoms/Head' -import PageLink from '../../../components/atoms/PageLink' -import { assetsBucketBaseUrl } from '../../../lib/consts' +import { Box, Card, Flex, Heading } from 'theme-ui' +import FormattedText from '../../../components/v2/FormattedText' +import { formatSubSkillInfo, replaceNewLine } from '../../../lib/v2/data/formatText' +import { loadWeaponCatalog, loadWeaponData } from '../../../lib/v2/server/loadData' +import { RootWeaponData } from '../../../lib/v2/data/types' +import { Fragment } from 'react' +import { getWeaponTypeLabel } from '../../../lib/v2/data/text' +import WeaponTypeIcon from '../../../components/v2/WeaponTypeIcon' +import WeaponIcon from '../../../components/v2/WeaponIcon' import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' -import { getBattlesuitMapByIds } from '../../../server/data/honkai3rd/battlesuits' -import { BattlesuitData } from '../../../lib/honkai3rd/battlesuits' -import BattlesuitCard from '../../../components/molecules/BattlesuitCard' -import WeaponCard from '../../../components/molecules/WeaponCard' +import Head from '../../../components/atoms/Head' +import { useTranslation } from 'next-i18next' +import { getI18NProps } from '../../../server/i18n' +import Breadcrumb from '../../../components/organisms/Breadcrumb' interface WeaponShowPageProps { - weapon: WeaponData - battlesuitMap: { [key: string]: BattlesuitData } - weaponMap: { [key: string]: WeaponData } + rootWeapon: RootWeaponData } -const WeaponShowPage = ({ weapon, battlesuitMap, weaponMap }: WeaponShowPageProps) => { +const WeaponShowPage = ({ rootWeapon }: WeaponShowPageProps) => { const { t } = useTranslation() + const weapon = rootWeapon.weapons[rootWeapon.weapons.length - 1] - const weaponCategoryName = t(`weapons-show.${weapon.category}`) - const weaponCategory = weaponCategories.find(category => category.value === weapon.category) + const weaponTypeLabel = getWeaponTypeLabel(weapon.type) + const atk = Math.floor(weapon.attackBase + weapon.attackAdd * (weapon.maxLv - 1)) + const crt = Math.floor(weapon.criticalBase + weapon.criticalAdd * (weapon.maxLv - 1)) return ( @@ -34,112 +32,78 @@ const WeaponShowPage = ({ weapon, battlesuitMap, weaponMap }: WeaponShowPageProp title={`${weapon.name} - ${t('common.honkai-3rd')} - ${t('common.abyss-lab')}`} description={`${t('common.honkai-3rd')} ${t('weapons-show.weapon')} / ${'⭐'.repeat( weapon.rarity - )} / ${weaponCategoryName} / ATK : ${weapon.atk} / CRT : ${weapon.crt}`} - canonicalHref={`/honkai3rd/weapons/${weapon.id}`} + )} / ${weaponTypeLabel} / ATK : ${atk} / CRT : ${crt}`} + canonicalHref={`/honkai3rd/v2/weapons/${weapon.id}`} /> - - + {weapon.name} - + - - - - {weaponCategory != null && ( - - )} - {weaponCategoryName} - - + {replaceNewLine(weapon.description)} + + + {getWeaponTypeLabel(weapon.type)} + + + ATK : {atk} / CRT : {crt} (at Max Lv {weapon.maxLv}) - - {'⭐'.repeat(weapon.rarity)} - - - ATK : {weapon.atk} / CRT : {weapon.crt} - - {weapon.battlesuits != null && weapon.battlesuits.length > 0 && ( - - {t('weapons-show.best-on')} - {weapon.battlesuits.map(({ id: battlesuitId }) => { - return - })} - - )} - {weapon.priWeapon != null && ( - - {t('weapons-show.pri-weapon')} - - - )} - {weapon.originalWeapons != null && weapon.originalWeapons.length > 0 && ( - - {t('weapons-show.original-weapon')} - {weapon.originalWeapons.map(originalWeaponId => { - return - })} - - )} - {/* {weapon.sources != null && ( - - {t('weapons-show.sources')} - {weapon.sources - .sort((a, b) => a.type.localeCompare(b.type)) - .map((source) => { - return - })} - - )} */} - + Skills + {weapon.skills.map(skill => { return ( - - - {skill.name} - - + + + {skill.name} + + + - {skill.description} - - + + {formatSubSkillInfo({ + info: skill.info, + maxLv: weapon.maxLv, + paramBase1: skill.param1, + paramBase2: skill.param2, + paramBase3: skill.param3, + paramAdd1: skill.param1Add, + paramAdd2: skill.param2Add, + paramAdd3: skill.param3Add + })} + + + ) })} - + + {/*
{JSON.stringify(weapon, null, 2)}
*/}
) @@ -147,43 +111,23 @@ const WeaponShowPage = ({ weapon, battlesuitMap, weaponMap }: WeaponShowPageProp export default WeaponShowPage -export async function getStaticProps({ params, locale }: NextPageContext & { params: { weaponId: string } }) { - const weapon = getWeaponById(params.weaponId, locale) - const battlesuitMap = getBattlesuitMapByIds( - weapon != null && weapon.battlesuits != null ? weapon.battlesuits.map(({ id }) => id) : [], - locale - ) - - const weaponIds = [] - if (weapon != null) { - if (weapon.priWeapon != null) { - weaponIds.push(weapon.priWeapon) - } - if (weapon.originalWeapons != null) { - weaponIds.push(...weapon.originalWeapons) - } - } - const weaponMap = getWeaponMapByIds(weaponIds, locale) +export async function getStaticProps({ locale, params }: NextPageContext & { params: { weaponId: string } }) { + const rootWeapon = loadWeaponData(params.weaponId) return { - props: { - weapon, - battlesuitMap, - weaponMap, - ...(await getI18NProps(locale)) - } + props: { rootWeapon, ...(await getI18NProps(locale)) } } } export async function getStaticPaths() { + const weaponCatalog = loadWeaponCatalog() + return { - paths: generateI18NPaths( - listWeapons().map(weapon => { - return { - params: { weaponId: weapon.id } - } - }) - ), + paths: weaponCatalog.map(catalogItem => { + return { + params: { weaponId: catalogItem.id } + } + }), fallback: false } } diff --git a/src/pages/honkai3rd/weapons/index.tsx b/src/pages/honkai3rd/weapons/index.tsx index 6f45aff8..168cb62e 100644 --- a/src/pages/honkai3rd/weapons/index.tsx +++ b/src/pages/honkai3rd/weapons/index.tsx @@ -1,90 +1,68 @@ /** @jsxImportSource theme-ui */ -import { Box, Heading, Flex } from '@theme-ui/components' -import Breadcrumb from '../../../components/organisms/Breadcrumb' -import { listWeapons } from '../../../server/data/honkai3rd/weapons' -import { pick } from 'ramda' -import { useMemo } from 'react' -import FilterButton from '../../../components/atoms/FilterButton' -import { useRouter } from 'next/router' -import { weaponCategories, WeaponData } from '../../../lib/honkai3rd/weapons' -import WeaponCard from '../../../components/molecules/WeaponCard' -import { getI18NProps } from '../../../server/i18n' +import { Box, Card } from '@theme-ui/components' import { NextPageContext } from 'next' -import { useTranslation, translate } from '../../../lib/i18n' +import { Flex, Heading, Link } from 'theme-ui' +import { loadWeaponCatalog } from '../../../lib/v2/server/loadData' +import { WeaponCatalogItem } from '../../../lib/v2/data/types' +import WeaponIcon from '../../../components/v2/WeaponIcon' import Head from '../../../components/atoms/Head' import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout' - -type WeaponListItemData = Pick +import { useTranslation } from 'next-i18next' +import { getI18NProps } from '../../../server/i18n' +import Breadcrumb from '../../../components/organisms/Breadcrumb' interface WeaponListPageProps { - weaponDataList: WeaponListItemData[] + weaponCatalog: WeaponCatalogItem[] } -const weaponFilterOptions = [{ value: 'all', label: 'All', krLabel: '전체', icon: undefined }, ...weaponCategories] - -const WeaponListPage = ({ weaponDataList }: WeaponListPageProps) => { - const { query, locale } = useRouter() +const WeaponListPage = ({ weaponCatalog }: WeaponListPageProps) => { const { t } = useTranslation() - - const categoryFilter = useMemo(() => { - if (query.category == null) { - return 'all' - } - - return typeof query.category === 'string' ? query.category : query.category[0] - }, [query]) - - const weaponList = useMemo(() => { - return weaponDataList.map(weapon => { - const hidden = isWeaponHidden(weapon, categoryFilter) - return