From e912cac6c8c0531f03a31d39e4a9a935a710f373 Mon Sep 17 00:00:00 2001 From: 1Telescope1 <2298908190@qq.com> Date: Tue, 18 Jun 2024 11:20:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9sidebar=E7=94=9F?= =?UTF-8?q?=E6=88=90=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/docs/.vitepress/config.mjs | 12 ++- demo/docs/config/sidebar.js | 152 -------------------------------- packages/website/lib/index.ts | 4 +- 3 files changed, 13 insertions(+), 155 deletions(-) diff --git a/demo/docs/.vitepress/config.mjs b/demo/docs/.vitepress/config.mjs index bc76308..4b8f159 100644 --- a/demo/docs/.vitepress/config.mjs +++ b/demo/docs/.vitepress/config.mjs @@ -1,8 +1,16 @@ import { defineConfig } from 'vitepress' import extendMarkdown from './highlight' import sidebarConfig from './../config/sidebar' +import fs from 'fs' +import path from 'path' function init() { + const dir = path.resolve(__dirname, '../guide') + const list = fs.readdirSync(dir).map(item => { + item = item.split('.')[0] + return { text: item, link: `/guide/${item}` } + }) + return defineConfig({ base: '/mpx-ui', title: 'mpx-cube-ui', @@ -22,8 +30,8 @@ function init() { themeConfig: { logo: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABFCAYAAAAW0YV7AAAAAXNSR0IArs4c6QAACD1JREFUeF7tm21QVNcZx//PuQuCKEpMrETESrTRKKCpiopjXRZcsfmQZko6cVozU2ea1s5E0QiKb0R5UTFR07QTP5ik+ZA2cTqZNqlRwGCqIEar0gQT32oUkQYrKMoG4e55OkvLBuRlz713FyGWb8z+/89zfvc59+w99zxL6MU/3pw8BJLXA5wCkhm0+uC+Xkzfmop6IyFztkD+3xYDnAvGQ96cRHuhBS+nzH1nemMcvQLMeSk/APQdYEzuEorQAojfQNBGWlV8M9DgAaswb1swGs1NBWBOU4IgXANoDVbP2U2ULZU8JkR+B+aCeWHQ3Zm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EeJrqFTcEzNQMQTuCQoJzSmePv6Waw9QqrRrcs7txF0U/S1LmMdhnx50qMIH+rAmxoswRe0F1LL50livcPgGXPDZINt9YA6Z0Bg/oLrkvYGKqJEHLypPjin0BGP3cr8DeaV4cHePW9ZcAPNnVgLoFZqojQeujHbGv7SFyG4VR0QcE2Au+f3SSlPoOJu7Qb3k3sKcliSFeiwjTNuyfNbFOZeBmNQEFbv0a4zRNFpY/B5YbGTzs7q8lYhTZbEgvTZpcaRbCiC/gwN5qH4qNkK76bLBcskFb849CTgwXoBXl8+L/YmTAVrW9BuwF3xv92Iu2zOmVI+e+vWfiRG9LklUQVX+vA6sOLFC6/wDprEyCnstzSQAAAABJRU5ErkJggg==', - sidebar: sidebarConfig, - // 搜索框 + sidebar: sidebarConfig.concat(list), + // 搜索框 search: { provider: 'local' }, diff --git a/demo/docs/config/sidebar.js b/demo/docs/config/sidebar.js index 0b10789..b7ac251 100644 --- a/demo/docs/config/sidebar.js +++ b/demo/docs/config/sidebar.js @@ -28,157 +28,5 @@ export default [ link: '/guide/contact' } ] - }, - { - text: '组件', - collapsable: false, - items: [ - { - text: '基础', - collapsable: false, - items: [ - { - text: 'Button 按钮', - link: '/components/base/button' - }, - { - text: 'ButtonGroup 按钮组', - link: '/components/base/button-group' - }, - { - text: 'Icon 图标', - link: '/components/base/icon' - }, - { - text: 'Divider 分割线', - link: '/components/base/divider' - }, - { - text: 'FloatBall 悬浮球', - link: '/components/base/float-ball' - } - // { - // text: 'Style 内置样式' - // } - // { - // text: '其他基础组件' - // } - ] - }, - { - text: '表单', - collapsable: false, - items: [ - { - text: 'Checkbox 复选框', - link: '/components/base/checkbox' - }, - { - text: 'CheckboxGroup 复选框组', - link: '/components/base/checkbox-group' - }, - { - text: 'Radio 单选框', - link: '/components/base/radio' - }, - { - text: 'RadioGroup 单选框组', - link: '/components/base/radio-group' - }, - { - text: 'Textarea 文本输入框', - link: '/components/base/textarea' - }, - { - text: 'Picker 选择器', - link: '/components/base/picker' - }, - { - text: 'CascadePicker 级联选择器', - link: '/components/base/cascade-picker' - }, - { - text: 'DatePicker 日期选择器', - link: '/components/base/date-picker' - }, - { - text: 'TimePicker 时间选择器', - link: '/components/base/time-picker' - } - ] - }, - { - text: '弹出层', - collapsable: false, - items: [ - { - text: 'Popup 弹出层', - link: '/components/popup/popup' - }, - { - text: 'Toast 轻提示', - link: '/components/popup/toast' - }, - { - text: 'Dialog 弹出框', - link: '/components/popup/dialog' - }, - { - text: 'Modal 半浮层弹窗', - link: '/components/popup/modal' - }, - { - text: 'Tip 提示', - link: '/components/base/tip' - } - ] - }, - { - text: '组合组件', - collapsable: false, - items: [ - { - text: 'RadioModal', - link: '/components/popup/radio-modal' - }, - { - text: 'CheckboxModal', - link: '/components/popup/checkbox-modal' - }, - { - text: 'PickerModal', - link: '/components/popup/picker-modal' - }, - { - text: 'CascadePickerModal', - link: '/components/popup/cascade-picker-modal' - }, - { - text: 'DatePickerModal', - link: '/components/popup/date-picker-modal' - }, - { - text: 'TimePickerModal', - link: '/components/popup/time-picker-modal' - }, - { - text: 'PickerPopup', - link: '/components/popup/picker-popup' - }, - { - text: 'CascadePickerPopup', - link: '/components/popup/cascade-picker-popup' - }, - { - text: 'DatePickerPopup', - link: '/components/popup/date-picker-popup' - }, - { - text: 'TimePickerPopup', - link: '/components/popup/time-picker-popup' - } - ] - } - ] } ] diff --git a/packages/website/lib/index.ts b/packages/website/lib/index.ts index 22856c0..e07f98d 100644 --- a/packages/website/lib/index.ts +++ b/packages/website/lib/index.ts @@ -37,7 +37,9 @@ function delScriptJsonBlock(content: string) { function delEmptyContentLineBreaks(content: string) { const scriptContentReg = /(?<=]*>)[\s\S]*(?=<\/script>)/ig - const scriptContent = content.match(scriptContentReg)[0] + const regRes = content.match(scriptContentReg) + if (!regRes) return '' + const scriptContent = regRes[0] const isEmpty = scriptContent && scriptContent.replace('\n', '').length === 0 if (isEmpty) { return content.replace(scriptContentReg, '')