手动安装
本指南将引导您手动安装和配置 Lunaria 到现有项目中。
1. 添加 @lunariajs/core 包
Lunaria 通过 npm 仓库中的 @lunariajs/core 包发布。请在项目根目录中运行以下命令,将其添加到您的项目中:
npm install @lunariajs/corepnpm install @lunariajs/coreyarn add @lunariajs/core然后,在您的 package.json 的 scripts 字段中添加以下 lunaria 命令:
"scripts": { "dev": "astro dev", "build": "astro build", "preview": "astro preview", "lunaria:build": "lunaria build", "lunaria:preview": "lunaria preview",}2. 创建 lunaria.config.json
Lunaria 使用 lunaria.config.json 进行配置。此文件是必需的,以便 Lunaria 了解您的仓库结构以及需要追踪的内容。
{ "$schema": "./node_modules/@lunariajs/core/config.schema.json"}3. 配置包
在生成第一个本地化仪表板之前,您必须设置 lunaria.config.json 文件中的 repository、defaultLocale 和 locales 字段。
以下示例将 Lunaria 配置为在一个示例项目中追踪英文和葡萄牙语的 Markdown/MDX 内容,该项目托管在 https://github.com/me/cool-project/:
{ "$schema": "./node_modules/@lunariajs/core/config.schema.json", "repository": { "name": "me/cool-docs" }, "files": [ { "location": "content/**/*.md", "pattern": "content/@lang/@path", "type": "universal" } ], "defaultLocale": { "label": "英语", "lang": "en" }, "locales": [ { "label": "葡萄牙语", "lang": "pt" } ]}详细了解所有可用选项,请参阅 配置参考指南。
4. 下一步
成功!您现在已经准备好在项目中使用 Lunaria 了!
如果您已完整遵循本指南,可以直接跳转至 构建您的第一个仪表板,学习如何生成本地化仪表板、在浏览器中查看,并了解我们的推荐下一步操作。