Skip to content

Commit 8870e08

Browse files
RylanBotanlyyao
andauthored
feat(site): add changelog for each component page (#3725)
* feat(site): add changelog for each component page * fix: support English and Chinese punctuation in description parsing * refactor: add mapping for parent and child components * chore: introduce plugin via common repository * fix: resolve conflicts * fix: fix dependency version mismatch * ci: add install-script --------- Co-authored-by: anlyyao <anly_yaw@163.com>
1 parent 341c983 commit 8870e08

10 files changed

Lines changed: 59 additions & 14 deletions

File tree

.github/workflows/pr-compressed-size.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ jobs:
1414
- uses: preactjs/compressed-size-action@v2
1515
with:
1616
repo-token: '${{ secrets.GITHUB_TOKEN }}'
17+
install-script: 'npm install'
1718
pattern: './miniprogram_dist/**/*.{js,wxs,wxml,json}'

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ docClass: timeline
88

99
## 🌈 1.9.5 `2025-06-13`
1010
### 🚀 Features
11-
- `Picker`: 新增 `content` 插槽,用于处理空数据场景;支持点击选中 @anlyyao ([#3711](https://github.com/Tencent/tdesign-miniprogram/pull/3711))([#3712](https://github.com/Tencent/tdesign-miniprogram/pull/3712))
11+
- `Picker`:
12+
- 新增 `content` 插槽,用于处理空数据场景 @anlyyao ([#3711](https://github.com/Tencent/tdesign-miniprogram/pull/3711))
13+
- 支持点击选中 @anlyyao ([#3712](https://github.com/Tencent/tdesign-miniprogram/pull/3712))
1214
- `Fab`: 未显示传入 `icon``text` 时将启用默认插槽,用于自定义悬浮按钮内容,此时 `buttonProps` 将失效 @novlan1 ([#3684](https://github.com/Tencent/tdesign-miniprogram/pull/3684))
1315
- `Upload`: 新增 `preview` 属性,用于关闭/开启图片预览 @anlyyao ([#3714](https://github.com/Tencent/tdesign-miniprogram/pull/3714))
1416
### 🐞 Bug Fixes

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
"lintfix": "eslint '{src,example}/**/*.{js,ts}' --fix",
2727
"lint": "eslint '{src,example}/**/*.{js,ts}'",
2828
"format": "prettier {src,example,script}/**/*.{js,ts,wxss,less,wxml,html,json,md,wxs} --write",
29-
"site": "cd site && vite build",
30-
"site:dev": "cd site && vite",
31-
"site:intranet": "cd site && vite build --mode intranet",
29+
"site": "cd site && vite build --configLoader runner",
30+
"site:dev": "cd site && vite --configLoader runner",
31+
"site:intranet": "cd site && vite build --mode intranet --configLoader runner",
3232
"site:prerender": "node script/prerender.mjs",
3333
"cover": "jest --coverage",
3434
"test": "jest && jest -c jest.e2e.config.js",
@@ -58,8 +58,8 @@
5858
"@types/node": "^20.14.11",
5959
"@typescript-eslint/eslint-plugin": "^5.6.0",
6060
"@typescript-eslint/parser": "~5.35.0",
61-
"@vitejs/plugin-vue": "^2.3.3",
62-
"@vitejs/plugin-vue-jsx": "^1.1.7",
61+
"@vitejs/plugin-vue": "^5.2.4",
62+
"@vitejs/plugin-vue-jsx": "^4.2.0",
6363
"@vue/compiler-sfc": "^3.2.4",
6464
"axios": "^1.1.3",
6565
"babel-jest": "^26.6.3",
@@ -110,12 +110,12 @@
110110
"stylelint": "^13.13.1",
111111
"tdesign-icons-view": "^0.3.6",
112112
"tdesign-publish-cli": "^0.0.12",
113-
"tdesign-site-components": "^0.15.2",
113+
"tdesign-site-components": "^0.16.0",
114114
"tdesign-theme-generator": "^1.1.0",
115115
"tinycolor2": "^1.4.2",
116116
"tslib": "^2.8.1",
117117
"typescript": "~4.7.2",
118-
"vite": "^2.7.6",
118+
"vite": "^6.2.3",
119119
"vite-plugin-tdoc": "^2.0.1",
120120
"vue": "^3.2.4",
121121
"vue-router": "^4.0.11"
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { promises } from 'fs';
2+
import path, { dirname } from 'path';
3+
import { fileURLToPath } from 'url';
4+
5+
import type { ViteDevServer } from 'vite';
6+
import generateChangelogJson from '../../../src/_common/docs/plugins/changelog-to-json';
7+
8+
const __dirname = dirname(fileURLToPath(import.meta.url));
9+
10+
const outputPath = path.resolve(__dirname, '../../dist/changelog.json');
11+
const changelogPath = path.resolve(__dirname, '../../../CHANGELOG.md');
12+
13+
export default function changelog2Json() {
14+
return {
15+
name: 'changelog-to-json',
16+
configureServer(server: ViteDevServer) {
17+
// 开发模式时拦截请求
18+
server.middlewares.use('/changelog.json', async (_, res) => {
19+
const json = await generateChangelogJson(changelogPath, 'mobile');
20+
res.setHeader('Content-Type', 'application/json');
21+
res.end(JSON.stringify(json));
22+
});
23+
},
24+
async closeBundle() {
25+
// 生产构建时写入物理文件
26+
if (process.env.NODE_ENV === 'production') {
27+
const json = await generateChangelogJson(changelogPath, 'mobile');
28+
await promises.writeFile(outputPath, JSON.stringify(json));
29+
}
30+
},
31+
};
32+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import fs from 'fs';
22
import path from 'path';
3+
import { fileURLToPath } from 'url';
34
import matter from 'gray-matter';
45

6+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
57
const componentPath = path.join(__dirname, './component.vue').replaceAll('\\', '/');
68

79
const DEFAULT_TABS = [
@@ -67,7 +69,7 @@ function customRender({ source, file, md }: any) {
6769

6870
// 设计指南内容 不展示 design Tab 则不解析
6971
if (pageData.isComponent && pageData.tdDocTabs.some((item) => item.tab === 'design')) {
70-
const designDocPath = path.resolve(__dirname, `../../src/_common/docs/mobile/design/${componentName}.md`);
72+
const designDocPath = path.resolve(__dirname, `../../../src/_common/docs/mobile/design/${componentName}.md`);
7173

7274
if (fs.existsSync(designDocPath)) {
7375
const designMd = fs.readFileSync(designDocPath, 'utf-8');
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
demoCodesImports = {};
1313

1414
// 增加渲染规则
15-
md.renderer.rules.html_block = function (tokens: string, idx: number) {
15+
md.renderer.rules.html_block = function (tokens: any[], idx: number) {
1616
const { content } = tokens[idx];
1717
if (content.startsWith('<img') && content.indexOf('qrcode') === -1) {
1818
return '';
@@ -25,6 +25,7 @@ export default {
2525
source = source.replace(/{{\s+(.+)\s+}}/g, (_: string, demoDirName: string) => {
2626
const demoPath = path.resolve(resourceDir, `./_example/${demoDirName}`);
2727
if (!fs.existsSync(demoPath)) {
28+
// eslint-disable-next-line no-console
2829
console.log('\x1B[36m%s\x1B[0m', `${name} 组件需要实现 _example/${demoDirName} 示例!`);
2930
return '\n<h3>DEMO (🚧建设中)...</h3>';
3031
}

site/vite.config.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import * as path from 'path';
1+
import path from 'path';
2+
import { fileURLToPath } from 'url';
23
import { defineConfig } from 'vite';
4+
5+
import rollupResolve from '@rollup/plugin-node-resolve';
36
import vue from '@vitejs/plugin-vue';
47
import vueJsx from '@vitejs/plugin-vue-jsx';
5-
import rollupResolve from '@rollup/plugin-node-resolve';
6-
import createTDesignPlugin from './plugin-tdoc';
8+
9+
import changelog2Json from './plugins/changelog-to-json';
10+
import createTDesignPlugin from './plugins/plugin-tdoc';
11+
12+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
713

814
const publicPathMap: Record<string, string> = {
915
preview: '/',
@@ -55,6 +61,7 @@ export default ({ mode }: any) => {
5561
}),
5662
vueJsx(),
5763
createTDesignPlugin(),
64+
changelog2Json(),
5865
],
5966
});
6067
};

src/_common

Submodule _common updated 187 files

0 commit comments

Comments
 (0)