Skip to content

Commit ab6d380

Browse files
committed
Ensure page titles are translate-able
1 parent ae476e4 commit ab6d380

23 files changed

+48
-35
lines changed

components/layout.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ export const PageContainer: FC<React.PropsWithChildren<unknown>> = ({
1414
}
1515

1616
export type LayoutProps = {
17-
title?: string
17+
titleI18nKey?: string
1818
}
1919

2020
export const Layout: React.FC<React.PropsWithChildren<LayoutProps>> = ({
2121
children,
22-
title
22+
titleI18nKey: titleKey
2323
}) => {
2424
const { authenticated, user } = useAuth()
2525
const { t } = useTranslation("common")
26-
const formattedTitle = title
27-
? `${title} | ${t("maple_abbr")}: ${t("maple_fullName")}`
26+
let title = titleKey
27+
? `${t(titleKey)} | ${t("maple_abbr")}: ${t("maple_fullName")}`
2828
: `${t("maple_abbr")}: ${t("maple_fullName")}`
2929

3030
// isClient used to prevent hydration issues: quite possibly better solutions exist
@@ -41,7 +41,7 @@ export const Layout: React.FC<React.PropsWithChildren<LayoutProps>> = ({
4141
{isClient ? (
4242
<>
4343
<Head>
44-
<title>{formattedTitle}</title>
44+
<title>{title}</title>
4545
<link rel="icon" href="/favicon.ico" />
4646
</Head>
4747
<FollowContext.Provider value={{ followStatus, setFollowStatus }}>

components/page.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ export type AppPropsWithLayout = AppProps & {
1313

1414
export function applyLayout({ Component, pageProps }: AppPropsWithLayout) {
1515
const page = <Component {...pageProps} />
16-
return <Layout title={Component.title}>{page}</Layout>
16+
return <Layout titleI18nKey={Component.titleI18nKey}>{page}</Layout>
1717
}
1818

19-
export type PageOptions<P> = {
20-
title?: string
21-
fullWidth?: boolean
22-
Page: NextPage<P>
23-
}
24-
25-
export function createPage<P>(options: PageOptions<P>): AppPage<P> {
19+
export function createPage<P>(
20+
options: {
21+
Page: NextPage<P>
22+
} & LayoutProps
23+
): AppPage<P> {
2624
const page: AppPage<P> = options.Page
27-
page.title = options.title
25+
page.titleI18nKey = options.titleI18nKey
2826
return page
2927
}

pages/about/faq-page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FaqPage } from "../../components/Faq/FaqPage"
33
import { createGetStaticTranslationProps } from "components/translations"
44

55
export default createPage({
6-
title: "About",
6+
titleI18nKey: "about",
77
Page: () => {
88
return <FaqPage />
99
}

pages/about/how-maple-uses-ai.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createGetStaticTranslationProps } from "components/translations"
33
import MapleAI from "components/about/MapleAI/MapleAI"
44

55
export default createPage({
6-
title: "How Maple Uses AI",
6+
titleI18nKey: "navigation.ai",
77
Page: () => {
88
return (
99
<div>

pages/about/mission-and-goals.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import GoalsAndMission from "../../components/GoalsAndMission/GoalsAndMission"
33
import { createGetStaticTranslationProps } from "components/translations"
44

55
export default createPage({
6-
title: "About",
6+
titleI18nKey: "about",
77
Page: () => {
88
return <GoalsAndMission />
99
}

pages/about/our-team.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createGetStaticTranslationProps } from "components/translations"
33
import { OurTeam } from "../../components/OurTeam/OurTeam"
44

55
export default createPage({
6-
title: "Our Team",
6+
titleI18nKey: "titles.our_team",
77
Page: () => {
88
return (
99
<div>

pages/about/support-maple.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SupportMaple from "../../components/about/SupportMaple/SupportMaple"
33
import { createGetStaticTranslationProps } from "components/translations"
44

55
export default createPage({
6-
title: "How to Support MAPLE",
6+
titleI18nKey: "titles.support_maple",
77
Page: () => {
88
return (
99
<div>

pages/admin.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useEffect } from "react"
88
// return <App />
99

1010
export default createPage({
11-
title: "Admin",
11+
titleI18nKey: "titles.admin",
1212
Page: requireAdmin(() => <App />)
1313
})
1414

pages/bills/[court]/[billId].tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { serverSideTranslations } from "next-i18next/serverSideTranslations"
1010
const Query = z.object({ court: z.coerce.number(), billId: z.string({}) })
1111

1212
export default createPage<{ bill: Bill }>({
13-
title: "Bill",
13+
titleI18nKey: "titles.bill",
1414
Page: ({ bill }) => {
1515
return (
1616
<>

pages/bills/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { BillSearch } from "components/search"
55
import { createGetStaticTranslationProps } from "components/translations"
66

77
export default createPage({
8-
title: "Browse Bills",
8+
titleI18nKey: "navigation.browseBills",
99
Page: () => {
1010
const { t } = useTranslation("billSearch")
1111

0 commit comments

Comments
 (0)