Skip to content

Commit

Permalink
feat: 设置vitepress的站点配置
Browse files Browse the repository at this point in the history
  • Loading branch information
1Telescope1 committed Jun 18, 2024
1 parent 63419df commit ffc5f08
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
node_modules
dist
.history
Expand All @@ -9,3 +10,4 @@ yarn.lock
packages/parser/lib/example.ts
.vscode/launch.json
packages/demo
demo/docs/.vitepress/cache
50 changes: 26 additions & 24 deletions demo/docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
import { defineConfig } from 'vitepress'
import fs from 'fs'
import path from 'path'
import extendMarkdown from './highlight'
import sidebarConfig from './../config/sidebar'

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: '/zc-test/mpx-ui/dist',
title: "My Awesome Project",
description: "A VitePress Site",
base: '/mpx-ui',
title: 'mpx-cube-ui',
description: 'mpx-cube-ui-description',
// 隐藏主题切换
appearance: false,
locales: {
'/': {
lang: 'zh-CN'
}
},
// 配置 Markdown 解析器选项
markdown: {
lineNumbers: true,
extendMarkdown
},
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
logo:
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABFCAYAAAAW0YV7AAAAAXNSR0IArs4c6QAACD1JREFUeF7tm21QVNcZx//PuQuCKEpMrETESrTRKKCpiopjXRZcsfmQZko6cVozU2ea1s5E0QiKb0R5UTFR07QTP5ik+ZA2cTqZNqlRwGCqIEar0gQT32oUkQYrKMoG4e55OkvLBuRlz713FyGWb8z+/89zfvc59+w99zxL6MU/3pw8BJLXA5wCkhm0+uC+Xkzfmop6IyFztkD+3xYDnAvGQ96cRHuhBS+nzH1nemMcvQLMeSk/APQdYEzuEorQAojfQNBGWlV8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prSXQXm96NGymC5BcBCox0A5oDpXyQ4qzwp/k0rv3swDdx2EfjD0TPdpO8EeJrqFTcEzNQMQTuCQoJzSmePv6Waw9QqrRrcs7txF0U/S1LmMdhnx50qMIH+rAmxoswRe0F1LL50livcPgGXPDZINt9YA6Z0Bg/oLrkvYGKqJEHLypPjin0BGP3cr8DeaV4cHePW9ZcAPNnVgLoFZqojQeujHbGv7SFyG4VR0QcE2Au+f3SSlPoOJu7Qb3k3sKcliSFeiwjTNuyfNbFOZeBmNQEFbv0a4zRNFpY/B5YbGTzs7q8lYhTZbEgvTZpcaRbCiC/gwN5qH4qNkK76bLBcskFb849CTgwXoBXl8+L/YmTAVrW9BuwF3xv92Iu2zOmVI+e+vWfiRG9LklUQVX+vA6sOLFC6/wDprEyCnstzSQAAAABJRU5ErkJggg==',
sidebar: sidebarConfig,
// 搜索框
search: {
provider: 'local'
},
nav: [
{ text: 'Examples', link: '/markdown-examples' }
],

sidebar: [
{
text: 'Examples',
items: list
text: 'GitHub',
link: 'https://github.com/didi/mpx-cube-ui'
}
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
]
}
})
Expand Down
16 changes: 16 additions & 0 deletions demo/docs/.vitepress/highlight/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* 代码高亮处理
*/
import hljs from 'highlight.js'

// 加入 v-pre 跳过 vue-compile,跳过 markdown-it fence render 流程
const wrapCode = (code, lang) =>
`<pre v-pre class="language-${lang}"><code>${code}</code></pre>`

export default md => {
md.options.highlight = (code, lang) => {
return wrapCode(hljs.highlight(code, {
language: lang !== 'vue' ? lang : 'html'
}).value, lang)
}
}
Empty file added demo/docs/config/nav.js
Empty file.
184 changes: 184 additions & 0 deletions demo/docs/config/sidebar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
export default [
{
text: '概览',
collapsable: false,
items: [
{
text: '介绍',
link: '/guide/intro'
},
{
text: '快速上手',
link: '/guide/quick-start'
},
{
text: '更新日志',
link: '/guide/changelog'
},
{
text: '主题与样式',
link: '/guide/theme'
},
{
text: '设计变量',
link: '/guide/design-tokens'
},
{
text: '联系我们',
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'
}
]
}
]
}
]
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"highlight.js": "11.9.0",
"typedoc": "^0.25.2",
"typedoc-plugin-missing-exports": "^2.1.0",
"vue-template-compiler": "^2.6.11"
Expand Down
17 changes: 15 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4673,6 +4673,11 @@ he@^1.1.0:
resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==

[email protected]:
version "11.9.0"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.9.0.tgz#04ab9ee43b52a41a047432c8103e2158a1b8b5b0"
integrity sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==

home-dir@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/home-dir/-/home-dir-1.0.0.tgz#2917eb44bdc9072ceda942579543847e3017fe4e"
Expand Down Expand Up @@ -8574,8 +8579,7 @@ string-length@^2.0.0:
astral-regex "^1.0.0"
strip-ansi "^4.0.0"

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
name string-width-cjs
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -8610,6 +8614,15 @@ string-width@^3.0.0, string-width@^3.1.0:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^5.1.0"

string-width@^4.1.0:
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^5.0.1, string-width@^5.1.2:
version "5.1.2"
resolved "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794"
Expand Down

0 comments on commit ffc5f08

Please sign in to comment.