Introduce i18n

This commit is contained in:
Sakura Knoll
2022-01-03 13:22:37 +09:00 Unverified
parent d6a8a0e7b0
commit 8bc576208a
20 changed files with 198 additions and 58 deletions
+7 -5
View File
@@ -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)) },
}
}
+4 -1
View File
@@ -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)),
},
}
}