contentlayerdev / contentlayerdev/contentlayer
Support for localization (e.g. for Contentful)
- 主要语言
- TypeScript
- 星标
- 3.5k
- 派生
- 192
- PR 合并指标
- 30 天内没有已合并 PR
描述
While I guess that it is currently possible to localize MDX based on frontmatter tags, doing this would mean that the filenames would need to be different, resulting in different slugs which would certainly not be ideal. I guess there are other ways to achieve it, but none of them seem ideal, that's why it would be great to support l10n (and also just because Contentlayers goal is to be the abstraction layer between data and code).
I assume that there could be several ways for structuring the MDX files, but what comes to my mind first is either via file name eg. `/pages/about.mdx` `/pages/about.de.mdx` or via subfolders eg. `/pages/en/about.mdx` `/pages/de/about.mdx`.
Edit: the following structure seems pretty nice, but would depend on #11
```bash
├── data
│ ├── pages
│ │ ├── about
│ │ │ ├── index.mdx
│ │ │ ├── index.de.mdx
│ │ │ ├── picture.jpeg
│ │ ├── privacy
│ │ │ ├── index.mdx
│ │ │ ├── index.de.mdx
│ │ │ ├── cover.jpeg
```
For Contentful one just needs to add `&locale=` https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/localization
贡献指南
调研方向
审查提议的 /pages/about.mdx 和 locale 子文件夹布局,然后阅读报告中链接的对 issue #11 的依赖以及 Contentful 本地化参考。定义本地化 MDX 和 Contentful 数据应如何表示,同时保留稳定的 slug;当所选结构和行为已完成文档记录并得到一致支持时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- content, localization
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100