Introduce i18n
This commit is contained in:
@@ -5,6 +5,7 @@ import SquareImageBox from '../../../components/atoms/SquareImageBox'
|
||||
import Breadcrumb from '../../../components/organisms/Breadcrumb'
|
||||
import Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator'
|
||||
import { WeaponData } from '../../../lib/honkai3rd/weapons'
|
||||
import { getI18NProps } from '../../../lib/i18n'
|
||||
import { capitalize } from '../../../lib/string'
|
||||
import {
|
||||
getWeaponById,
|
||||
@@ -80,12 +81,14 @@ const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => {
|
||||
|
||||
export default WeaponShowPage
|
||||
|
||||
export function getStaticProps(
|
||||
context: NextPageContext & { params: { weaponId: string } }
|
||||
) {
|
||||
const weapon = getWeaponById(context.params.weaponId)
|
||||
export async function getStaticProps({
|
||||
params,
|
||||
locale,
|
||||
}: NextPageContext & { params: { weaponId: string } }) {
|
||||
const weapon = getWeaponById(params.weaponId)
|
||||
|
||||
return {
|
||||
props: { weapon },
|
||||
props: { weapon, ...(await getI18NProps(locale)) },
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import FilterButton from '../../../components/atoms/FilterButton'
|
||||
import { useRouter } from 'next/router'
|
||||
import { WeaponData } from '../../../lib/honkai3rd/weapons'
|
||||
import WeaponCard from '../../../components/molecules/WeaponCard'
|
||||
import { getI18NProps } from '../../../lib/i18n'
|
||||
import { NextPageContext } from 'next'
|
||||
|
||||
type WeaponListItemData = Pick<
|
||||
WeaponData,
|
||||
@@ -94,12 +96,13 @@ const WeaponListPage = ({ weaponDataList }: WeaponListPageProps) => {
|
||||
|
||||
export default WeaponListPage
|
||||
|
||||
export async function getStaticProps() {
|
||||
export async function getStaticProps({ locale }: NextPageContext) {
|
||||
return {
|
||||
props: {
|
||||
weaponDataList: listWeapons().map((weapon) => {
|
||||
return pick(['name', 'id', 'rarity', 'category'], weapon)
|
||||
}),
|
||||
...(await getI18NProps(locale)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user