-
Notifications
You must be signed in to change notification settings - Fork 576
docs(site): add site metadata #5947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
TDesign Component Site Preview Open
|
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a new site metadata management system that replaces the previous approach of generating a catalogs.ts file at build time. The change introduces a Vite plugin that dynamically loads package version information from the workspace YAML configuration and makes it available as a global constant.
- Adds a new Vite plugin
siteMetadatathat reads package versions from pnpm-workspace.yaml - Replaces static catalog imports with a global
TD_SITE_METADATAconstant for dependency management - Removes the catalogs.ts generation step from the build process
Reviewed Changes
Copilot reviewed 12 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/tdesign-vue-next/site/vite.config.ts | Adds the new siteMetadata plugin to the Vite configuration |
| packages/tdesign-vue-next/site/src/components/stackblitz/content.ts | Replaces catalog imports with TD_SITE_METADATA global references |
| packages/tdesign-vue-next/site/src/components/codeSandbox/content.ts | Updates to use TD_SITE_METADATA instead of imported catalogs |
| packages/tdesign-vue-next/site/plugins/site-metadata/index.ts | New Vite plugin that defines TD_SITE_METADATA from workspace YAML |
| packages/tdesign-vue-next-chat/site/vite.config.ts | Adds siteMetadata plugin and updates import paths |
| packages/tdesign-vue-next-chat/site/src/components/stackblitz/content.js | Replaces catalog imports with TD_SITE_METADATA references |
| packages/tdesign-vue-next-chat/site/plugins/site-metadata/index.js | Chat package version of the siteMetadata plugin |
| packages/tdesign-vue-next-chat/site/plugins/plugin-doc/md-to-vue.js | Fixes import path for common docs utilities |
| packages/tdesign-vue-next-chat/site/package.json | Adds --configLoader runner flag to Vite commands |
| internal/utils/src/catalogs.ts | Removes the generated catalogs file entirely |
| internal/utils/scripts/postinstall-tasks.ts | Removes catalog generation from build process |
| internal/utils/index.ts | Removes catalogs export from utils package |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| import { readFileSync } from 'fs'; | ||
| import { joinWorkspaceRoot, tdesignVueNextPackageJson } from '@tdesign/internal-utils'; | ||
| export default function siteMetadata() { | ||
| const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml'); | ||
| const yamlContent = readFileSync(sourcePath, 'utf-8'); | ||
| const documents = parse(yamlContent); |
Copilot
AI
Aug 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the YAML file synchronously on every plugin initialization could cause performance issues and lacks error handling. Consider adding try-catch blocks and validating the file exists.
| import { readFileSync } from 'fs'; | |
| import { joinWorkspaceRoot, tdesignVueNextPackageJson } from '@tdesign/internal-utils'; | |
| export default function siteMetadata() { | |
| const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml'); | |
| const yamlContent = readFileSync(sourcePath, 'utf-8'); | |
| const documents = parse(yamlContent); | |
| import { readFileSync, existsSync } from 'fs'; | |
| import { joinWorkspaceRoot, tdesignVueNextPackageJson } from '@tdesign/internal-utils'; | |
| export default function siteMetadata() { | |
| const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml'); | |
| let documents: any = {}; | |
| if (existsSync(sourcePath)) { | |
| try { | |
| const yamlContent = readFileSync(sourcePath, 'utf-8'); | |
| documents = parse(yamlContent); | |
| } catch (err) { | |
| console.warn(`[site-metadata] Failed to read or parse YAML file at ${sourcePath}:`, err); | |
| documents = {}; | |
| } | |
| } else { | |
| console.warn(`[site-metadata] YAML file not found at ${sourcePath}.`); | |
| documents = {}; | |
| } |
| import { readFileSync } from 'fs'; | ||
| import { joinWorkspaceRoot, tdesignVueNextPackageJson, tdesignVueNextChatPackageJson } from '@tdesign/internal-utils'; | ||
| export default function siteMetadata() { | ||
| const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml'); | ||
| const yamlContent = readFileSync(sourcePath, 'utf-8'); | ||
| const documents = parse(yamlContent); |
Copilot
AI
Aug 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading the YAML file synchronously on every plugin initialization could cause performance issues and lacks error handling. Consider adding try-catch blocks and validating the file exists.
| import { readFileSync } from 'fs'; | |
| import { joinWorkspaceRoot, tdesignVueNextPackageJson, tdesignVueNextChatPackageJson } from '@tdesign/internal-utils'; | |
| export default function siteMetadata() { | |
| const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml'); | |
| const yamlContent = readFileSync(sourcePath, 'utf-8'); | |
| const documents = parse(yamlContent); | |
| import { readFileSync, existsSync } from 'fs'; | |
| import { joinWorkspaceRoot, tdesignVueNextPackageJson, tdesignVueNextChatPackageJson } from '@tdesign/internal-utils'; | |
| export default function siteMetadata() { | |
| const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml'); | |
| let documents = {}; | |
| if (existsSync(sourcePath)) { | |
| try { | |
| const yamlContent = readFileSync(sourcePath, 'utf-8'); | |
| documents = parse(yamlContent); | |
| } catch (err) { | |
| // eslint-disable-next-line no-console | |
| console.warn(`[site-metadata] Failed to read or parse YAML file at ${sourcePath}:`, err); | |
| documents = {}; | |
| } | |
| } else { | |
| // eslint-disable-next-line no-console | |
| console.warn(`[site-metadata] YAML file not found at ${sourcePath}.`); | |
| documents = {}; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以聊聊为什么要这样修改吗?我的疑问在于
- 本质上没有改变获取 catalogs 的思路,都是读 yml
- 无法复用:由于当前 site 没有整合的缘故,还是重复的,多个 site 就要编写多次;同时还无法给到其它模块使用
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要获取依赖版本只有站点在使用,而且每次动到依赖版本catalogs.ts都会产生一个变更出来,我认为做成插件供站点使用好点

🤔 这个 PR 的性质是?
🔗 相关 Issue
💡 需求背景和解决方案
优化#5800
移除编译生成catalogs.ts,改用vite 插件生成站点数据存储依赖版本号
📝 更新日志
tdesign-vue-next
@tdesign-vue-next/chat
@tdesign-vue-next/auto-import-resolver
☑️ 请求合并前的自查清单