Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { getTranslations } from "next-intl/server";
import { notFound } from "next/navigation";
import { buildAlternates, openGraphDefaults, seoDescription, twitterSummary } from "../../../../i18n/seo";
import { Callout } from "../../components/callout";
import { CodeBlock } from "../../components/code-block";
import { DocsHeading } from "../../components/docs-heading";
import { baseDocsLocales } from "../../components/docs-nav-items";
import { Callout } from "@/app/[locale]/components/callout";
import { CodeBlock } from "@/app/[locale]/components/code-block";
import { DocsHeading } from "@/app/[locale]/components/docs-heading";
import { baseDocsLocales } from "@/app/[locale]/components/docs-nav-items";
import {
buildAlternates,
openGraphDefaults,
seoDescription,
twitterSummary,
} from "@/i18n/seo";

function assertSupportedLocale(locale: string) {
if (!baseDocsLocales.includes(locale as (typeof baseDocsLocales)[number])) {
Expand Down
2 changes: 1 addition & 1 deletion web/app/[locale]/(landing)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ function HomeContent() {
</div>
<div className="flex justify-center gap-4 mt-6">
<Link
href="/docs"
href="/docs/getting-started"
className="text-sm text-muted hover:text-foreground transition-colors underline underline-offset-2 decoration-link-underline hover:decoration-foreground"
>
{tc("readTheDocs")}
Expand Down
4 changes: 4 additions & 0 deletions web/i18n/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ export const routing = defineRouting({
locales,
defaultLocale: "en",
localePrefix: "as-needed",
// Route-level metadata owns hreflang because some pages intentionally support
// only a subset of locales. A global Link header advertises localized URLs
// that return 404 for those pages.
alternateLinks: false,
Comment thread
lawrencecchen marked this conversation as resolved.
Resolved
});
7 changes: 7 additions & 0 deletions web/tests/seo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ describe("SEO metadata helpers", () => {
});

describe("SEO middleware", () => {
test("does not advertise unsupported locale variants globally", () => {
const response = middleware(requestFor("/docs/base"));

expect(response.status).toBe(200);
expect(response.headers.get("link")).toBeNull();
});

test("serves the English remote tmux docs without locale redirect loops", () => {
const unsupportedLocale = middleware(
requestFor("/de/docs/remote-tmux", { "accept-language": "de" }),
Expand Down