feat: language switch links to same post in other language
Deploy / build (push) Successful in 10s

- Add translation field to schema + auto-match by zh/ prefix
- BaseLayout accepts per-page switchHref; post page resolves translation link
- Falls back to section landing (/ or /zh/) when no translation exists
This commit is contained in:
hoelee committed 2026-09-06 06:50:37 +08:00
1 parent 677fc7cb20
commit 6b56c1f4db
3 files changed
+20 -3

No files matched your search

+3
View File
@@ -21,6 +21,9 @@ const posts = defineCollection({
// lang is NOT set in frontmatter anymore — it's derived from the folder:
// posts/hello-world.md -> en (flat)
// posts/zh/hello-world.md -> zh (subfolder)
// Explicit link to the other-language version (its full slug, e.g. "zh/how-i-host-this-blog").
// When absent, the language switch falls back to the section landing page (/ or /zh/).
translation: z.string().optional(),
ogImage: z.string().optional(),
}),
});