docs: 统一文档为 pnpm astro sync,避免误导;同步提交 env/tsconfig 调整

This commit is contained in:
2025-11-27 17:29:44 +08:00
parent c38606d675
commit 6302a7baef
5 changed files with 9 additions and 5 deletions
+3
View File
@@ -9,5 +9,8 @@ dist/
public/images/ public/images/
ref/ ref/
# Environment variables
.env
# Miscellaneous # Miscellaneous
.DS_Store .DS_Store
+1 -1
View File
@@ -67,7 +67,7 @@
- Astro 的高保真类型来自 `.astro/types.d.ts`,由 `astro dev``astro sync` 生成。 - Astro 的高保真类型来自 `.astro/types.d.ts`,由 `astro dev``astro sync` 生成。
- Node 要求:`>= 18.20.8`(建议 `>= 20`)。Node 版本不足会导致 `astro sync` 失败,类型退化为 `any`(如 `getCollection(...args: any[]): any`)。 - Node 要求:`>= 18.20.8`(建议 `>= 20`)。Node 版本不足会导致 `astro sync` 失败,类型退化为 `any`(如 `getCollection(...args: any[]): any`)。
- 操作规范: - 操作规范:
- 在“非沙盒/本机环境”执行:`astro sync``pnpm dev`,以生成 `.astro/types.d.ts` - 在“非沙盒/本机环境”执行:`pnpm astro sync``pnpm dev`,以生成 `.astro/types.d.ts`
- 如在沙盒内执行需要更高权限,请先申请再运行,或直接在沙盒外执行。 - 如在沙盒内执行需要更高权限,请先申请再运行,或直接在沙盒外执行。
- 若类型仍不生效:删除 `.astro/` 后重跑 `pnpm sync`;确保编辑器使用工作区 TypeScript 版本。 - 若类型仍不生效:删除 `.astro/` 后重跑 `pnpm sync`;确保编辑器使用工作区 TypeScript 版本。
+2 -1
View File
@@ -20,10 +20,11 @@
- 通用组件:`src/components/`(如 `Img.astro` 支持外部图床) - 通用组件:`src/components/`(如 `Img.astro` 支持外部图床)
- 内容扩展抽象:`src/lib/content/`(为未来 Typst 等格式预留) - 内容扩展抽象:`src/lib/content/`(为未来 Typst 等格式预留)
## 配置 ## 配置与类型
- `PUBLIC_MEDIA_BASE_URL`:外部图床前缀(避免图片入库) - `PUBLIC_MEDIA_BASE_URL`:外部图床前缀(避免图片入库)
- `PUBLIC_SITE_URL`:站点地址(可选,用于 canonical 等) - `PUBLIC_SITE_URL`:站点地址(可选,用于 canonical 等)
- 修改内容集合(src/content/config.ts)后,需在本机运行 `pnpm astro sync`Node >= 18.20.8,建议 >= 20),以生成 `.astro/types.d.ts`,否则类型可能退化为 any。
## 约定 ## 约定
+1 -1
View File
@@ -1,4 +1,5 @@
/// <reference types="astro/client" /> /// <reference types="astro/client" />
/// <reference path="../.astro/types.d.ts" />
interface ImportMetaEnv { interface ImportMetaEnv {
readonly PUBLIC_MEDIA_BASE_URL?: string; readonly PUBLIC_MEDIA_BASE_URL?: string;
@@ -8,4 +9,3 @@ interface ImportMetaEnv {
interface ImportMeta { interface ImportMeta {
readonly env: ImportMetaEnv; readonly env: ImportMetaEnv;
} }
+1 -1
View File
@@ -17,7 +17,7 @@
}, },
"include": [ "include": [
"src", "src",
"env.d.ts", "src/env.d.ts",
"astro.config.mjs", "astro.config.mjs",
".astro/types.d.ts" ".astro/types.d.ts"
], ],