feat: 构建文档基础框架
This commit is contained in:
@@ -23,6 +23,14 @@ export default defineConfig({
|
|||||||
|
|
||||||
socialLinks: [
|
socialLinks: [
|
||||||
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
|
{ icon: 'github', link: 'https://github.com/vuejs/vitepress' }
|
||||||
]
|
],
|
||||||
|
|
||||||
|
search: {
|
||||||
|
provider: 'local'
|
||||||
|
},
|
||||||
|
|
||||||
|
lastUpdated: {
|
||||||
|
text: '最近更新',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
3
docs/.vitepress/theme/custom.css
Normal file
3
docs/.vitepress/theme/custom.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
:root {
|
||||||
|
--vp-sidebar-width: 320px;
|
||||||
|
}
|
@@ -3,6 +3,7 @@ import { h } from 'vue'
|
|||||||
import type { Theme } from 'vitepress'
|
import type { Theme } from 'vitepress'
|
||||||
import DefaultTheme from 'vitepress/theme'
|
import DefaultTheme from 'vitepress/theme'
|
||||||
import './style.css'
|
import './style.css'
|
||||||
|
import './custom.css'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
extends: DefaultTheme,
|
extends: DefaultTheme,
|
||||||
|
47
docs/components/contents.vue
Normal file
47
docs/components/contents.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<template>
|
||||||
|
<!-- ------------------- -->
|
||||||
|
<!--
|
||||||
|
<br>
|
||||||
|
props.base: {{ props.base }}
|
||||||
|
<br>
|
||||||
|
props.sidebarItem.base: {{ props.sidebarItem.base }}
|
||||||
|
<br>
|
||||||
|
-->
|
||||||
|
<p v-if="props.sidebarItem.text">
|
||||||
|
<a v-if="props.sidebarItem.link" @click="goTo(props.sidebarItem.link)" style="cursor: pointer;">
|
||||||
|
{{ props.sidebarItem.text }}
|
||||||
|
</a>
|
||||||
|
<span style="font-weight: bold;" v-else>
|
||||||
|
{{ props.sidebarItem.text }}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
<!-- ------------------- -->
|
||||||
|
|
||||||
|
<!-- <pre>{{ page }}</pre> -->
|
||||||
|
|
||||||
|
<div v-if="props.sidebarItem.items" :style="props.sidebarItem.text ? 'margin-left: 25px;' : undefined">
|
||||||
|
<contents v-for="item in props.sidebarItem.items" :base="props.sidebarItem.base || props.base"
|
||||||
|
:sidebar-item="item" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { useData, useRouter, DefaultTheme } from 'vitepress';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
base?: string,
|
||||||
|
sidebarItem: DefaultTheme.SidebarItem
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const { page } = useData()
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
|
function goTo(link: string) {
|
||||||
|
const target = (props.base || '') + link?.replace('.md', '.html')
|
||||||
|
console.log('base', props.base)
|
||||||
|
console.log('link', link)
|
||||||
|
console.log('target', target)
|
||||||
|
router.go(target)
|
||||||
|
}
|
||||||
|
</script>
|
3
docs/how-to/database/mysql/install-on-ubuntu.md
Normal file
3
docs/how-to/database/mysql/install-on-ubuntu.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# MySQL 8.x 数据库安装配置 (Ubuntu 系统)
|
||||||
|
|
||||||
|
待完善
|
3
docs/how-to/database/mysql/install-on-windows.md
Normal file
3
docs/how-to/database/mysql/install-on-windows.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# MySQL 8.x 数据库安装配置 (Windows 系统)
|
||||||
|
|
||||||
|
待完善
|
10
docs/how-to/index.md
Normal file
10
docs/how-to/index.md
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# How to ... ? 如何做系列教程
|
||||||
|
|
||||||
|
请在左侧选择教程。
|
||||||
|
|
||||||
|
<contents :sidebar-item="sidebar['/how-to/']" />
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import contents from '/components/contents.vue'
|
||||||
|
import { sidebar } from '/sidebar.mts';
|
||||||
|
</script>
|
@@ -12,6 +12,9 @@ hero:
|
|||||||
tagline: My great project tagline
|
tagline: My great project tagline
|
||||||
actions:
|
actions:
|
||||||
- theme: brand
|
- theme: brand
|
||||||
|
text: 进入教程
|
||||||
|
link: /how-to
|
||||||
|
- theme: alt
|
||||||
text: Markdown Examples
|
text: Markdown Examples
|
||||||
link: /markdown-examples
|
link: /markdown-examples
|
||||||
- theme: alt
|
- theme: alt
|
||||||
|
15
docs/nav.mts
15
docs/nav.mts
@@ -1,6 +1,17 @@
|
|||||||
import { DefaultTheme } from 'vitepress'
|
import { DefaultTheme } from 'vitepress'
|
||||||
|
|
||||||
export const nav: DefaultTheme.NavItem[] = [
|
export const nav: DefaultTheme.NavItem[] = [
|
||||||
{ text: 'Home', link: '/' },
|
{
|
||||||
{ text: 'Examples', link: '/markdown-examples' }
|
text: 'Home',
|
||||||
|
link: '/',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Home2',
|
||||||
|
link: '/how-to/index',
|
||||||
|
activeMatch: '/how-to/',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Examples',
|
||||||
|
link: '/markdown-examples',
|
||||||
|
},
|
||||||
]
|
]
|
@@ -1,11 +1,70 @@
|
|||||||
import { DefaultTheme } from 'vitepress'
|
import { DefaultTheme } from 'vitepress'
|
||||||
|
|
||||||
export const sidebar: DefaultTheme.Sidebar = [
|
const serialNumberMap = {}
|
||||||
{
|
|
||||||
text: 'Examples',
|
function serial(key) {
|
||||||
items: [
|
if (!serialNumberMap[key]) {
|
||||||
{ text: 'Markdown Examples', link: '/markdown-examples' },
|
serialNumberMap[key] = 0
|
||||||
{ text: 'Runtime API Examples', link: '/api-examples' }
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
const serialNumber = ++serialNumberMap[key] // `${++serialNumberMap[key]}. `
|
||||||
|
// return
|
||||||
|
if (!key.includes('.')) {
|
||||||
|
return `🌟 `
|
||||||
|
}
|
||||||
|
return `✨ `
|
||||||
|
}
|
||||||
|
|
||||||
|
export const sidebar: DefaultTheme.Sidebar = {
|
||||||
|
'/how-to/': {
|
||||||
|
base: '/how-to/',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: '开始',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: '教程简介',
|
||||||
|
link: '/index.md',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Linux 系统如何 ... ?',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: `${serial('linux')}安装数据库`,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: `${serial('linux.db')}MySQL 8.x 安装 & 配置 (Ubuntu)`,
|
||||||
|
link: 'database/mysql/install-on-ubuntu.md',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: 'Windows 系统如何 ... ?',
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: `${serial('win')}安装数据库`,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
text: `${serial('win.db')}MySQL 8.x 安装 & 配置`,
|
||||||
|
link: 'database/mysql/install-on-windows.md',
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
'/': [
|
||||||
|
|
||||||
|
{
|
||||||
|
text: 'Examples',
|
||||||
|
items: [
|
||||||
|
{ text: 'Markdown Examples', link: '/markdown-examples' },
|
||||||
|
{ text: 'Runtime API Examples', link: '/api-examples' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Reference in New Issue
Block a user