Skip to content

Commit 33256c5

Browse files
committed
fix: re-localize in-content links for shared collections in documentation
1 parent d24d104 commit 33256c5

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/pages/[lang]/[...slug].astro

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { docsMenu } from '@/config/menu/docs';
88
import { apiMenu } from '@/config/menu/api';
99
import { resourcesMenu } from '@/config/menu/resources';
1010
import { DEFAULT_VERSION, VERSION_PREFIXES } from '@/config/versions';
11+
import LocalizedLink from '@components/patterns/LocalizedLink/LocalizedLink.astro';
1112
import type { LanguageCode } from '@i18n/locales';
1213
1314
export async function getStaticPaths() {
@@ -204,6 +205,10 @@ const { prev, next } = getAdjacentPages(
204205
const editUrl = isTranslation
205206
? `https://github.com/expressjs/expressjs.com/blob/main/docs/i18n.md`
206207
: `https://github.com/expressjs/expressjs.com/edit/main/${page.filePath}`;
208+
209+
// Shared collections (api/blog) are compiled once, so their in-content links are
210+
// baked to the default language. Re-localize them per render-language.
211+
const isSharedCollection = page.collection === 'api' || page.collection === 'blog';
207212
---
208213

209214
<DocLayout
@@ -215,5 +220,5 @@ const editUrl = isTranslation
215220
prev={prev}
216221
next={next}
217222
>
218-
<Content />
223+
{isSharedCollection ? <Content components={{ a: LocalizedLink }} /> : <Content />}
219224
</DocLayout>

0 commit comments

Comments
 (0)