From 330e8c7bbfc792f4a29cdaa08dec8b35c75b2a30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=A6=82=E6=91=B8=E9=B1=BC=E5=8E=BB?=
<1780903673@qq.com>
Date: Sat, 9 Nov 2024 23:25:34 +0800
Subject: [PATCH] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20=20=E6=96=87?=
=?UTF-8?q?=E6=A1=A3=E6=96=B0=E5=A2=9E=E6=BC=94=E7=A4=BA=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E6=BA=90=E7=A0=81=E5=92=8C=E7=BB=84=E4=BB=B6=E6=BA=90=E7=A0=81?=
=?UTF-8?q?=E9=93=BE=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
docs/.vitepress/config.mts | 8 +++--
docs/.vitepress/plugins/markdown-transform.ts | 24 +++++++++++++
.../theme/components/ExternalLink.vue | 36 +++++++++++++++++++
docs/.vitepress/theme/index.ts | 6 ++--
4 files changed, 70 insertions(+), 4 deletions(-)
create mode 100644 docs/.vitepress/plugins/markdown-transform.ts
create mode 100644 docs/.vitepress/theme/components/ExternalLink.vue
diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts
index 0e96bb75..f90bcf5f 100644
--- a/docs/.vitepress/config.mts
+++ b/docs/.vitepress/config.mts
@@ -1,18 +1,22 @@
/*
* @Author: weisheng
* @Date: 2023-07-27 10:26:09
- * @LastEditTime: 2024-11-03 13:30:06
+ * @LastEditTime: 2024-11-09 21:52:24
* @LastEditors: weisheng
* @Description:
- * @FilePath: \wot-design-uni\docs\.vitepress\config.mts
+ * @FilePath: /wot-design-uni/docs/.vitepress/config.mts
* 记得注释
*/
import { defineConfig } from 'vitepress';
import viteCompression from 'vite-plugin-compression'
+import { MarkdownTransform } from './plugins/markdown-transform'
+
+
export default defineConfig({
vite: {
plugins: [
+ MarkdownTransform(),
viteCompression({
verbose: true,
disable: false,
diff --git a/docs/.vitepress/plugins/markdown-transform.ts b/docs/.vitepress/plugins/markdown-transform.ts
new file mode 100644
index 00000000..b1e299f3
--- /dev/null
+++ b/docs/.vitepress/plugins/markdown-transform.ts
@@ -0,0 +1,24 @@
+import type { Plugin } from 'vite'
+import { camelCase } from '../../../src/uni_modules/wot-design-uni/components/common/util'
+import path from 'path'
+export function MarkdownTransform(): Plugin {
+ return {
+ name: 'md-transform',
+ enforce: 'pre',
+ async transform(code, id) {
+ if (!id.endsWith('.md')) return
+ if (!code.includes('')) return
+ const GITHUB_URL = 'https://github.com/Moonofweisheng/wot-design-uni/tree/master'
+ const componentId = path.basename(id, '.md')
+ const componentName = `wd-${componentId}`
+ const camelComponentId = camelCase(componentId)
+ const demoUrl = `${GITHUB_URL}/src/pages/${camelComponentId}`
+ const componentUrl = `${GITHUB_URL}/src/uni_modules/wot-design-uni/components/${componentName}`
+ return {
+ code:`${code}\n## 源代码\n文档 • 组件`
+ }
+ },
+ }
+}
+
+
\ No newline at end of file
diff --git a/docs/.vitepress/theme/components/ExternalLink.vue b/docs/.vitepress/theme/components/ExternalLink.vue
new file mode 100644
index 00000000..2311c801
--- /dev/null
+++ b/docs/.vitepress/theme/components/ExternalLink.vue
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts
index 0214e309..5628e3ec 100644
--- a/docs/.vitepress/theme/index.ts
+++ b/docs/.vitepress/theme/index.ts
@@ -1,10 +1,10 @@
/*
* @Author: weisheng
* @Date: 2024-10-12 22:09:33
- * @LastEditTime: 2024-11-03 13:26:13
+ * @LastEditTime: 2024-11-09 23:03:07
* @LastEditors: weisheng
* @Description:
- * @FilePath: \wot-design-uni\docs\.vitepress\theme\index.ts
+ * @FilePath: /wot-design-uni/docs/.vitepress/theme/index.ts
* 记得注释
*/
import { h } from 'vue'
@@ -19,6 +19,7 @@ import CustomFooter from './components/CustomFooter.vue'
import SvgImage from './components/SvgImage.vue'
import HomeStar from './components/HomeStar.vue'
import frame from './components/frame.vue'
+import ExternalLink from './components/ExternalLink.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
@@ -36,6 +37,7 @@ export default {
enhanceApp({ app }) {
app.component('SvgImage', SvgImage)
app.component('frame', frame)
+ app.component('ExternalLink',ExternalLink)
app.use(ElementPlus)
},
}