Update 6.6 data
This commit is contained in:
@@ -4,12 +4,7 @@ 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 { BattlesuitData, battlesuitFeatures, battlesuitTypes, valkyries } from '../../../lib/honkai3rd/battlesuits'
|
||||
import BattlesuitCard from '../../../components/molecules/BattlesuitCard'
|
||||
import { useRouter } from 'next/router'
|
||||
import { NextPageContext } from 'next'
|
||||
@@ -18,10 +13,7 @@ import { translate, useTranslation } from '../../../lib/i18n'
|
||||
import Head from '../../../components/atoms/Head'
|
||||
import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout'
|
||||
|
||||
type BattlesuitListItemData = Pick<
|
||||
BattlesuitData,
|
||||
'id' | 'name' | 'features' | 'type' | 'valkyrie'
|
||||
>
|
||||
type BattlesuitListItemData = Pick<BattlesuitData, 'id' | 'name' | 'features' | 'type' | 'valkyrie'>
|
||||
|
||||
interface BattlesuitListPageProps {
|
||||
battlesuits: BattlesuitListItemData[]
|
||||
@@ -39,11 +31,7 @@ const valkyrieFilterOptions: {
|
||||
label: string
|
||||
icon?: string
|
||||
krLabel?: string
|
||||
}[] = [
|
||||
{ value: 'all', label: 'All', krLabel: '전체' },
|
||||
...battlesuitTypes,
|
||||
...valkyries,
|
||||
]
|
||||
}[] = [{ value: 'all', label: 'All', krLabel: '전체' }, ...battlesuitTypes, ...valkyries]
|
||||
|
||||
const BattlesuitListPage = ({ battlesuits }: BattlesuitListPageProps) => {
|
||||
const { query, locale } = useRouter()
|
||||
@@ -59,9 +47,7 @@ const BattlesuitListPage = ({ battlesuits }: BattlesuitListPageProps) => {
|
||||
return 'all'
|
||||
}
|
||||
|
||||
return typeof query.valkyrie === 'string'
|
||||
? query.valkyrie
|
||||
: query.valkyrie[0]
|
||||
return typeof query.valkyrie === 'string' ? query.valkyrie : query.valkyrie[0]
|
||||
}, [query])
|
||||
|
||||
const featureFilter = useMemo(() => {
|
||||
@@ -73,31 +59,22 @@ const BattlesuitListPage = ({ battlesuits }: BattlesuitListPageProps) => {
|
||||
}, [query])
|
||||
|
||||
const battlesuitsFiteredByValkyrie = useMemo(() => {
|
||||
return battlesuits.filter((battlesuit) =>
|
||||
isValkyrieFilterMatching(battlesuit, valkyrieFilter)
|
||||
)
|
||||
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 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)
|
||||
)
|
||||
return battlesuitsFiteredByValkyrie.filter(battlesuit => isFeatureFilterMatching(battlesuit, featureFilter))
|
||||
}, [battlesuitsFiteredByValkyrie, featureFilter])
|
||||
|
||||
return (
|
||||
<Honkai3rdLayout>
|
||||
<Head
|
||||
title={`${t('common.battlesuits')} - ${t('common.honkai-3rd')} - ${t(
|
||||
'common.abyss-lab'
|
||||
)}`}
|
||||
title={`${t('common.battlesuits')} - ${t('common.honkai-3rd')} - ${t('common.abyss-lab')}`}
|
||||
description={t('battlesuits-list.description')}
|
||||
canonicalHref={`/honkai3rd/battlesuits`}
|
||||
/>
|
||||
@@ -108,19 +85,19 @@ const BattlesuitListPage = ({ battlesuits }: BattlesuitListPageProps) => {
|
||||
{ href: '/honkai3rd', label: t('common.honkai-3rd') },
|
||||
{
|
||||
href: '/honkai3rd/battlesuits',
|
||||
label: t('common.battlesuits'),
|
||||
},
|
||||
label: t('common.battlesuits')
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
||||
<Heading as='h1'>{t('battlesuits-list.heading')}</Heading>
|
||||
<Heading as="h1">{t('battlesuits-list.heading')}</Heading>
|
||||
|
||||
<Box sx={{ display: ['block', 'none'], mb: 2 }}>
|
||||
<Button
|
||||
className={hiddenFilters ? '' : 'active'}
|
||||
sx={{ px: 2, py: 1 }}
|
||||
onClick={() => {
|
||||
setHiddenFilters((previousValue) => !previousValue)
|
||||
setHiddenFilters(previousValue => !previousValue)
|
||||
}}
|
||||
>
|
||||
{t('battlesuits-list.filters')}
|
||||
@@ -131,11 +108,11 @@ const BattlesuitListPage = ({ battlesuits }: BattlesuitListPageProps) => {
|
||||
sx={{
|
||||
display: 'block',
|
||||
'&.hidden': {
|
||||
display: ['none', 'block'],
|
||||
},
|
||||
display: ['none', 'block']
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Heading as='h3'>{t('battlesuits-list.filter-by-valkyries')}</Heading>
|
||||
<Heading as="h3">{t('battlesuits-list.filter-by-valkyries')}</Heading>
|
||||
<Flex mb={2} sx={{ flexWrap: 'wrap' }}>
|
||||
{valkyrieFilterOptions.map(({ value, label, icon, krLabel }) => {
|
||||
return (
|
||||
@@ -151,10 +128,10 @@ const BattlesuitListPage = ({ battlesuits }: BattlesuitListPageProps) => {
|
||||
)
|
||||
})}
|
||||
</Flex>
|
||||
<Heading as='h3'>{t('battlesuits-list.filter-by-features')}</Heading>
|
||||
<Heading as="h3">{t('battlesuits-list.filter-by-features')}</Heading>
|
||||
<Flex mb={2} sx={{ flexWrap: 'wrap' }}>
|
||||
{featureFilterOptions
|
||||
.filter((filterOption) => {
|
||||
.filter(filterOption => {
|
||||
if (filterOption.value === 'all') {
|
||||
return true
|
||||
}
|
||||
@@ -179,13 +156,11 @@ const BattlesuitListPage = ({ battlesuits }: BattlesuitListPageProps) => {
|
||||
<Flex
|
||||
sx={{
|
||||
flexWrap: 'wrap',
|
||||
justifyContent: 'space-around',
|
||||
justifyContent: 'space-around'
|
||||
}}
|
||||
>
|
||||
{battlesuitsFilteredByFeature.map((battlesuit) => {
|
||||
return (
|
||||
<BattlesuitCard key={battlesuit.id} battlesuit={battlesuit} />
|
||||
)
|
||||
{battlesuitsFilteredByFeature.map(battlesuit => {
|
||||
return <BattlesuitCard key={battlesuit.id} battlesuit={battlesuit} />
|
||||
})}
|
||||
</Flex>
|
||||
</Box>
|
||||
@@ -198,24 +173,21 @@ export default BattlesuitListPage
|
||||
export async function getStaticProps({ locale }: NextPageContext) {
|
||||
return {
|
||||
props: {
|
||||
battlesuits: listBattlesuits(locale).map((battlesuit) => {
|
||||
battlesuits: listBattlesuits(locale).map(battlesuit => {
|
||||
return {
|
||||
id: battlesuit.id,
|
||||
name: battlesuit.name,
|
||||
features: battlesuit.features,
|
||||
type: battlesuit.type,
|
||||
valkyrie: battlesuit.valkyrie,
|
||||
valkyrie: battlesuit.valkyrie
|
||||
}
|
||||
}),
|
||||
...(await getI18NProps(locale)),
|
||||
},
|
||||
...(await getI18NProps(locale))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isValkyrieFilterMatching(
|
||||
battlesuit: BattlesuitListItemData,
|
||||
valkyrieFilter: string
|
||||
) {
|
||||
function isValkyrieFilterMatching(battlesuit: BattlesuitListItemData, valkyrieFilter: string) {
|
||||
switch (valkyrieFilter) {
|
||||
case 'mecha':
|
||||
case 'biologic':
|
||||
@@ -245,7 +217,11 @@ function isValkyrieFilterMatching(
|
||||
case 'aponia':
|
||||
case 'eden':
|
||||
case 'griseo':
|
||||
case 'vill-v':
|
||||
case 'sushang':
|
||||
case 'ai':
|
||||
case 'susannah':
|
||||
case 'misteln':
|
||||
case 'prometheus':
|
||||
return battlesuit.valkyrie === valkyrieFilter
|
||||
default:
|
||||
case 'all':
|
||||
@@ -253,12 +229,9 @@ function isValkyrieFilterMatching(
|
||||
}
|
||||
}
|
||||
|
||||
function isFeatureFilterMatching(
|
||||
battlesuit: BattlesuitListItemData,
|
||||
featureFilter: string
|
||||
) {
|
||||
function isFeatureFilterMatching(battlesuit: BattlesuitListItemData, featureFilter: string) {
|
||||
if (featureFilter === 'all') {
|
||||
return true
|
||||
}
|
||||
return battlesuit.features.some((feature) => feature === featureFilter)
|
||||
return battlesuit.features.some(feature => feature === featureFilter)
|
||||
}
|
||||
|
||||
@@ -5,11 +5,7 @@ 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 { 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'
|
||||
@@ -26,29 +22,19 @@ interface WeaponShowPageProps {
|
||||
weaponMap: { [key: string]: WeaponData }
|
||||
}
|
||||
|
||||
const WeaponShowPage = ({
|
||||
weapon,
|
||||
battlesuitMap,
|
||||
weaponMap,
|
||||
}: WeaponShowPageProps) => {
|
||||
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
|
||||
)
|
||||
const weaponCategory = weaponCategories.find(category => category.value === weapon.category)
|
||||
|
||||
return (
|
||||
<Honkai3rdLayout>
|
||||
<Head
|
||||
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}`}
|
||||
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}`}
|
||||
/>
|
||||
|
||||
@@ -59,12 +45,12 @@ const WeaponShowPage = ({
|
||||
{ href: '/honkai3rd/weapons', label: t('common.weapons') },
|
||||
{
|
||||
href: `/honkai3rd/weapons/${weapon.id}`,
|
||||
label: weapon.name,
|
||||
},
|
||||
label: weapon.name
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
||||
<Heading as='h1'>{weapon.name}</Heading>
|
||||
<Heading as="h1">{weapon.name}</Heading>
|
||||
|
||||
<Box mb={3}>
|
||||
<SquareImageBox
|
||||
@@ -79,7 +65,7 @@ const WeaponShowPage = ({
|
||||
<PageLink
|
||||
href={{
|
||||
pathname: '/honkai3rd/weapons',
|
||||
query: { category: weapon.category },
|
||||
query: { category: weapon.category }
|
||||
}}
|
||||
>
|
||||
<Flex>
|
||||
@@ -103,39 +89,26 @@ const WeaponShowPage = ({
|
||||
</Box>
|
||||
{weapon.battlesuits != null && weapon.battlesuits.length > 0 && (
|
||||
<Box sx={{ p: 2, borderTop: 'default' }}>
|
||||
<Heading as='h4'>{t('weapons-show.best-on')}</Heading>
|
||||
<Heading as="h4">{t('weapons-show.best-on')}</Heading>
|
||||
{weapon.battlesuits.map(({ id: battlesuitId }) => {
|
||||
return (
|
||||
<BattlesuitCard
|
||||
key={battlesuitId}
|
||||
size='sm'
|
||||
battlesuit={battlesuitMap[battlesuitId]}
|
||||
/>
|
||||
)
|
||||
return <BattlesuitCard key={battlesuitId} size="sm" battlesuit={battlesuitMap[battlesuitId]} />
|
||||
})}
|
||||
</Box>
|
||||
)}
|
||||
{weapon.priWeapon != null && (
|
||||
<Box sx={{ p: 2, borderTop: 'default' }}>
|
||||
<Heading as='h4'>{t('weapons-show.pri-weapon')}</Heading>
|
||||
<WeaponCard size='sm' weapon={weaponMap[weapon.priWeapon]} />
|
||||
<Heading as="h4">{t('weapons-show.pri-weapon')}</Heading>
|
||||
<WeaponCard size="sm" weapon={weaponMap[weapon.priWeapon]} />
|
||||
</Box>
|
||||
)}
|
||||
{weapon.originalWeapons != null && weapon.originalWeapons.length > 0 && (
|
||||
<Box sx={{ p: 2, borderTop: 'default' }}>
|
||||
<Heading as="h4">{t('weapons-show.original-weapon')}</Heading>
|
||||
{weapon.originalWeapons.map(originalWeaponId => {
|
||||
return <WeaponCard key={originalWeaponId} size="sm" weapon={weaponMap[originalWeaponId]} />
|
||||
})}
|
||||
</Box>
|
||||
)}
|
||||
{weapon.originalWeapons != null &&
|
||||
weapon.originalWeapons.length > 0 && (
|
||||
<Box sx={{ p: 2, borderTop: 'default' }}>
|
||||
<Heading as='h4'>{t('weapons-show.original-weapon')}</Heading>
|
||||
{weapon.originalWeapons.map((originalWeaponId) => {
|
||||
return (
|
||||
<WeaponCard
|
||||
key={originalWeaponId}
|
||||
size='sm'
|
||||
weapon={weaponMap[originalWeaponId]}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</Box>
|
||||
)}
|
||||
{/* {weapon.sources != null && (
|
||||
<Box sx={{ p: 2, borderTop: 'default' }}>
|
||||
<Heading as='h4'>{t('weapons-show.sources')}</Heading>
|
||||
@@ -149,16 +122,16 @@ const WeaponShowPage = ({
|
||||
</Card>
|
||||
|
||||
<Box>
|
||||
{weapon.skills.map((skill) => {
|
||||
{weapon.skills.map(skill => {
|
||||
return (
|
||||
<Card key={skill.name} mb={3}>
|
||||
<Heading as='h3' p={2} m={0} sx={{ borderBottom: 'default' }}>
|
||||
<Heading as="h3" p={2} m={0} sx={{ borderBottom: 'default' }}>
|
||||
{skill.name}
|
||||
</Heading>
|
||||
<Paragraph
|
||||
p={2}
|
||||
sx={{
|
||||
whiteSpace: 'pre-wrap',
|
||||
whiteSpace: 'pre-wrap'
|
||||
}}
|
||||
>
|
||||
{skill.description}
|
||||
@@ -174,15 +147,10 @@ const WeaponShowPage = ({
|
||||
|
||||
export default WeaponShowPage
|
||||
|
||||
export async function getStaticProps({
|
||||
params,
|
||||
locale,
|
||||
}: NextPageContext & { params: { weaponId: string } }) {
|
||||
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)
|
||||
: [],
|
||||
weapon != null && weapon.battlesuits != null ? weapon.battlesuits.map(({ id }) => id) : [],
|
||||
locale
|
||||
)
|
||||
|
||||
@@ -202,20 +170,20 @@ export async function getStaticProps({
|
||||
weapon,
|
||||
battlesuitMap,
|
||||
weaponMap,
|
||||
...(await getI18NProps(locale)),
|
||||
},
|
||||
...(await getI18NProps(locale))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
return {
|
||||
paths: generateI18NPaths(
|
||||
listWeapons().map((weapon) => {
|
||||
listWeapons().map(weapon => {
|
||||
return {
|
||||
params: { weaponId: weapon.id },
|
||||
params: { weaponId: weapon.id }
|
||||
}
|
||||
})
|
||||
),
|
||||
fallback: false,
|
||||
fallback: false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,19 +14,13 @@ import { useTranslation, translate } from '../../../lib/i18n'
|
||||
import Head from '../../../components/atoms/Head'
|
||||
import Honkai3rdLayout from '../../../components/layouts/Honkai3rdLayout'
|
||||
|
||||
type WeaponListItemData = Pick<
|
||||
WeaponData,
|
||||
'id' | 'name' | 'rarity' | 'category'
|
||||
>
|
||||
type WeaponListItemData = Pick<WeaponData, 'id' | 'name' | 'rarity' | 'category'>
|
||||
|
||||
interface WeaponListPageProps {
|
||||
weaponDataList: WeaponListItemData[]
|
||||
}
|
||||
|
||||
const weaponFilterOptions = [
|
||||
{ value: 'all', label: 'All', krLabel: '전체', icon: undefined },
|
||||
...weaponCategories,
|
||||
]
|
||||
const weaponFilterOptions = [{ value: 'all', label: 'All', krLabel: '전체', icon: undefined }, ...weaponCategories]
|
||||
|
||||
const WeaponListPage = ({ weaponDataList }: WeaponListPageProps) => {
|
||||
const { query, locale } = useRouter()
|
||||
@@ -37,13 +31,11 @@ const WeaponListPage = ({ weaponDataList }: WeaponListPageProps) => {
|
||||
return 'all'
|
||||
}
|
||||
|
||||
return typeof query.category === 'string'
|
||||
? query.category
|
||||
: query.category[0]
|
||||
return typeof query.category === 'string' ? query.category : query.category[0]
|
||||
}, [query])
|
||||
|
||||
const weaponList = useMemo(() => {
|
||||
return weaponDataList.map((weapon) => {
|
||||
return weaponDataList.map(weapon => {
|
||||
const hidden = isWeaponHidden(weapon, categoryFilter)
|
||||
return <WeaponCard key={weapon.id} weapon={weapon} hidden={hidden} />
|
||||
})
|
||||
@@ -53,9 +45,7 @@ const WeaponListPage = ({ weaponDataList }: WeaponListPageProps) => {
|
||||
<Honkai3rdLayout>
|
||||
<Box>
|
||||
<Head
|
||||
title={`${t('common.weapons')} - ${t('common.honkai-3rd')} - ${t(
|
||||
'common.abyss-lab'
|
||||
)}`}
|
||||
title={`${t('common.weapons')} - ${t('common.honkai-3rd')} - ${t('common.abyss-lab')}`}
|
||||
description={t('weapons-list.description')}
|
||||
canonicalHref={`/honkai3rd/weapons`}
|
||||
/>
|
||||
@@ -64,13 +54,13 @@ const WeaponListPage = ({ weaponDataList }: WeaponListPageProps) => {
|
||||
<Breadcrumb
|
||||
items={[
|
||||
{ href: '/honkai3rd', label: t('common.honkai-3rd') },
|
||||
{ href: '/honkai3rd/weapons', label: t('common.weapons') },
|
||||
{ href: '/honkai3rd/weapons', label: t('common.weapons') }
|
||||
]}
|
||||
/>
|
||||
|
||||
<Heading as='h1'>{t('weapons-list.weapons')}</Heading>
|
||||
<Heading as="h1">{t('weapons-list.weapons')}</Heading>
|
||||
<Box>
|
||||
<Heading as='h3'>{t('weapons-list.filter-by-category')}</Heading>
|
||||
<Heading as="h3">{t('weapons-list.filter-by-category')}</Heading>
|
||||
<Flex mb={2} sx={{ flexWrap: 'wrap' }}>
|
||||
{weaponFilterOptions.map(({ value, label, krLabel, icon }) => {
|
||||
return (
|
||||
@@ -89,7 +79,7 @@ const WeaponListPage = ({ weaponDataList }: WeaponListPageProps) => {
|
||||
<Flex
|
||||
sx={{
|
||||
flexWrap: 'wrap',
|
||||
justifyContent: 'space-around',
|
||||
justifyContent: 'space-around'
|
||||
}}
|
||||
>
|
||||
{weaponList}
|
||||
@@ -105,11 +95,11 @@ export default WeaponListPage
|
||||
export async function getStaticProps({ locale }: NextPageContext) {
|
||||
return {
|
||||
props: {
|
||||
weaponDataList: listWeapons(locale).map((weapon) => {
|
||||
weaponDataList: listWeapons(locale).map(weapon => {
|
||||
return pick(['name', 'id', 'rarity', 'category'], weapon)
|
||||
}),
|
||||
...(await getI18NProps(locale)),
|
||||
},
|
||||
...(await getI18NProps(locale))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +115,7 @@ function isWeaponHidden(weapon: WeaponListItemData, filter: string): boolean {
|
||||
case 'lance':
|
||||
case 'bow':
|
||||
case 'chakram':
|
||||
case 'javelin':
|
||||
return weapon.category !== filter
|
||||
default:
|
||||
case 'all':
|
||||
|
||||
Reference in New Issue
Block a user