Introduce i18n
This commit is contained in:
@@ -8,6 +8,7 @@ import SecondaryLabel from '../../../components/atoms/SecondaryLabel'
|
||||
import Breadcrumb from '../../../components/organisms/Breadcrumb'
|
||||
import Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator'
|
||||
import { ElfData } from '../../../lib/honkai3rd/elfs'
|
||||
import { getI18NProps } from '../../../lib/i18n'
|
||||
import { capitalize } from '../../../lib/string'
|
||||
import { getElfById, listElfs } from '../../../server/data/honkai3rd/elfs'
|
||||
|
||||
@@ -103,12 +104,13 @@ const ElfShowPage = ({ elf }: ElfShowPageProps) => {
|
||||
|
||||
export default ElfShowPage
|
||||
|
||||
export function getStaticProps(
|
||||
context: NextPageContext & { params: { elfId: string } }
|
||||
) {
|
||||
const elf = getElfById(context.params.elfId)
|
||||
export async function getStaticProps({
|
||||
params,
|
||||
locale,
|
||||
}: NextPageContext & { params: { elfId: string } }) {
|
||||
const elf = getElfById(params.elfId)
|
||||
return {
|
||||
props: { elf },
|
||||
props: { elf, ...(await getI18NProps(locale)) },
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
/** @jsxImportSource theme-ui */
|
||||
import { Box, Heading, Flex } 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 Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator'
|
||||
import { ElfData } from '../../../lib/honkai3rd/elfs'
|
||||
import { getI18NProps } from '../../../lib/i18n'
|
||||
import { listElfs } from '../../../server/data/honkai3rd/elfs'
|
||||
|
||||
interface ElfListPageProps {
|
||||
@@ -43,10 +45,11 @@ const ElfListPage = ({ elfs }: ElfListPageProps) => {
|
||||
|
||||
export default ElfListPage
|
||||
|
||||
export async function getStaticProps() {
|
||||
export async function getStaticProps({ locale }: NextPageContext) {
|
||||
return {
|
||||
props: {
|
||||
elfs: listElfs().map((elf) => pick(['id', 'name'], elf)),
|
||||
...(await getI18NProps(locale)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user