-
Notifications
You must be signed in to change notification settings - Fork 577
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
Open
liweijie0812
wants to merge
3
commits into
develop
Choose a base branch
from
docs/site/metadata
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,5 @@ | ||
| import { parse } from 'yaml'; | ||
| import { readFileSync, writeFileSync } from 'fs'; | ||
| import { joinWorkspaceRoot } from '../src/paths'; | ||
| import { run } from '../src/exec'; | ||
|
|
||
| // 1. generate catalog.ts | ||
| const CATALOG_PATH = './internal/utils/src/catalogs.ts'; | ||
| const sourcePath = joinWorkspaceRoot('pnpm-workspace.yaml'); | ||
| const destPath = joinWorkspaceRoot(CATALOG_PATH); | ||
| const yamlContent = readFileSync(sourcePath, 'utf-8'); | ||
| const documents = parse(yamlContent); | ||
| writeFileSync(destPath, `export const catalogs = ${JSON.stringify(documents.catalogs, null, 2)}`); | ||
| run(`npx prettier --write ${CATALOG_PATH}`, { cwd: joinWorkspaceRoot() }); | ||
|
|
||
| // 2. rollup.config.ts | ||
| // rollup.config.ts | ||
| run('npx rollup -c rollup.config.ts', { cwd: joinWorkspaceRoot('internal/utils') }); |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
36 changes: 36 additions & 0 deletions
36
packages/tdesign-vue-next-chat/site/plugins/site-metadata/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import { parse } from 'yaml'; | ||
| 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); | ||
| return { | ||
| name: 'site-metadata', | ||
| config() { | ||
| return { | ||
| define: { | ||
| TD_SITE_METADATA: JSON.stringify({ | ||
| dependencies: { | ||
| vue: documents.catalogs.deps.vue, | ||
| less: documents.catalogs.bundle.less, | ||
| clipboard: documents.catalogs.deps.clipboard, | ||
| marked: documents.catalogs.deps.marked, | ||
| 'tdesign-vue-next': tdesignVueNextPackageJson.version, | ||
| 'tdesign-icons-vue-next': documents.catalogs.tdesign['tdesign-icons-vue-next'], | ||
| '@tdesign-vue-next/chat': tdesignVueNextChatPackageJson.version, | ||
| 'highlight.js': documents.catalogs.deps['highlight.js'], | ||
| 'marked-highlight': documents.catalogs.docs['marked-highlight'], | ||
| }, | ||
| devDependencies: { | ||
| vite: documents.catalogs.bundle.vite, | ||
| '@vue/compiler-sfc': documents.catalogs.bundle['@vue/compiler-sfc'], | ||
| '@vitejs/plugin-vue': documents.catalogs.bundle['@vitejs/plugin-vue'], | ||
| '@vitejs/plugin-vue-jsx': documents.catalogs.bundle['@vitejs/plugin-vue-jsx'], | ||
| }, | ||
| }), | ||
| }, | ||
| }; | ||
| }, | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/tdesign-vue-next/site/plugins/site-metadata/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { parse } from 'yaml'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 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); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+2
to
+7
|
||||||||||||||||||||||||||||||||||||||||||||||||
| 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 = {}; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
可以聊聊为什么要这样修改吗?我的疑问在于
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都会产生一个变更出来,我认为做成插件供站点使用好点