feat: add localized home routes

This commit is contained in:
TerryM
2026-06-01 15:09:58 +08:00
parent 9b08379d50
commit fa78568c94
8 changed files with 144 additions and 18 deletions

View File

@@ -1,6 +1,7 @@
import { useEffect, useMemo } from "react";
import { useLocation } from "react-router-dom";
import { useI18n, type Lang } from "../i18n";
import { isHomePathname } from "../languageRoutes";
type PageMeta = {
title: string;
@@ -83,7 +84,7 @@ function routeMeta(
const q = params.get("q")?.trim();
const sort = params.get("sort");
if (pathname === "/") {
if (isHomePathname(pathname)) {
return {
title: t("heroTitle"),
description: metaDescription(lang, "home"),
@@ -146,7 +147,9 @@ export function DocumentMeta() {
useEffect(() => {
const brand = t("brand");
const title = pathname === "/" ? meta.title : `${meta.title} | ${brand}`;
const title = isHomePathname(pathname)
? meta.title
: `${meta.title} | ${brand}`;
const canonical = `${window.location.origin}${pathname}${search}`;
document.documentElement.lang = lang;