该项目设置
项目设置目录
bash
.vitepress
├─sidebar
├─theme // 主要存放项目主题样式,全局注册ui库
├─config.mts // 主项目设置
├─nav.ts // 头部导航设置
├─socialLinks.ts // 仓库链接设置
└─themeConfig.ts // 项目主题设置
.vitepress
├─sidebar
├─theme // 主要存放项目主题样式,全局注册ui库
├─config.mts // 主项目设置
├─nav.ts // 头部导航设置
├─socialLinks.ts // 仓库链接设置
└─themeConfig.ts // 项目主题设置
config.mts
ts
import { defineConfig } from 'vitepress';
import themeConfig from './themeConfig';
import { demoblockPlugin, demoblockVitePlugin } from 'vitepress-theme-demoblock';
// https://vitepress.dev/reference/site-config
export default defineConfig({
base: '/gh-blogs', //网站base url,如果你想部署到码云、github,需要与仓库名一样
outDir: './../docs', //打包输出目录
title: 'GH BLOGS', //网站标题
titleTemplate: 'A blog site of Wu Guanghui', //网站副标题
description: 'A blog site of Wu Guanghui',
markdown: {
config: (md) => {
md.use(demoblockPlugin);
}, //markdown中使用代码块
},
vite: {
plugins: [demoblockVitePlugin()],
},
head: [['link', { rel: 'icon', href: './logo.webp' }]], //网页logo配置,浏览器tab页logo
themeConfig, //主题配置
});
import { defineConfig } from 'vitepress';
import themeConfig from './themeConfig';
import { demoblockPlugin, demoblockVitePlugin } from 'vitepress-theme-demoblock';
// https://vitepress.dev/reference/site-config
export default defineConfig({
base: '/gh-blogs', //网站base url,如果你想部署到码云、github,需要与仓库名一样
outDir: './../docs', //打包输出目录
title: 'GH BLOGS', //网站标题
titleTemplate: 'A blog site of Wu Guanghui', //网站副标题
description: 'A blog site of Wu Guanghui',
markdown: {
config: (md) => {
md.use(demoblockPlugin);
}, //markdown中使用代码块
},
vite: {
plugins: [demoblockVitePlugin()],
},
head: [['link', { rel: 'icon', href: './logo.webp' }]], //网页logo配置,浏览器tab页logo
themeConfig, //主题配置
});
nav.ts
ts
import type { DefaultTheme } from 'vitepress';
// https://vitepress.dev/reference/default-theme-nav
export default [
{ text: 'home', link: '/' },
{ text: 'GHUI', link: '/ghui/搭建组件库流程', activeMatch: '/ghui/' },
{
text: 'blogs',
activeMatch: '/blogs/',
items: [
{ text: 'html', link: '/a' },
{ text: 'css', link: '/blogs/css/常用片段', activeMatch: '/css/' },
{ text: 'JavaScript', link: '/blogs/js/JS基础', activeMatch: '/js/' },
{ text: 'vue', link: '/a' },
{ text: 'vite', link: '/a' },
{ text: 'mini program', link: '/a' },
{ text: 'algorithm', link: '/a' },
{ text: 'UniApp', link: '/a' },
{ text: 'flutter', link: '/a' },
{ text: 'react', link: '/a' },
{ text: 'compiler', link: '/a' },
{ text: 'vitepress', link: '/blogs/vitepress/起步', activeMatch: '/vitepress/' },
{ text: 'back-end', link: '/b' },
],
},
] as DefaultTheme.NavItem[];
import type { DefaultTheme } from 'vitepress';
// https://vitepress.dev/reference/default-theme-nav
export default [
{ text: 'home', link: '/' },
{ text: 'GHUI', link: '/ghui/搭建组件库流程', activeMatch: '/ghui/' },
{
text: 'blogs',
activeMatch: '/blogs/',
items: [
{ text: 'html', link: '/a' },
{ text: 'css', link: '/blogs/css/常用片段', activeMatch: '/css/' },
{ text: 'JavaScript', link: '/blogs/js/JS基础', activeMatch: '/js/' },
{ text: 'vue', link: '/a' },
{ text: 'vite', link: '/a' },
{ text: 'mini program', link: '/a' },
{ text: 'algorithm', link: '/a' },
{ text: 'UniApp', link: '/a' },
{ text: 'flutter', link: '/a' },
{ text: 'react', link: '/a' },
{ text: 'compiler', link: '/a' },
{ text: 'vitepress', link: '/blogs/vitepress/起步', activeMatch: '/vitepress/' },
{ text: 'back-end', link: '/b' },
],
},
] as DefaultTheme.NavItem[];
socialLinks.ts
ts
import type { DefaultTheme } from 'vitepress';
export default [
{ icon: 'github', link: 'https://github.com/SheenJs/gh-blogs' },
] as DefaultTheme.SocialLink[];
import type { DefaultTheme } from 'vitepress';
export default [
{ icon: 'github', link: 'https://github.com/SheenJs/gh-blogs' },
] as DefaultTheme.SocialLink[];
themeConfig.ts
ts
import type { DefaultTheme } from 'vitepress';
import nav from './nav';
import sidebar from './sidebar/index';
import socialLinks from './socialLinks';
// https://vitepress.dev/reference/default-theme-config
export default {
logo: '/logo.webp', //logo
//开启本地搜索
search: {
provider: 'local',
},
nav, //头部导航
sidebar, //侧边栏
socialLinks, //项目仓库地址
outlineTitle: '章节导航', // 文章导航提示
docFooter: {
prev: '←上一篇',
next: '下一篇→',
}, //自定义上一篇下一篇按钮文字
lastUpdatedText: '上次更新时间',
//跳转到仓库编辑
editLink: {
text: '在github编辑该页面',
pattern: 'https://github.com/SheenJs/gh-blogs/tree/main/develop/:path',
},
// 底部配置
footer: {
message: '',
copyright: 'Copyright © 2023 YGHHJS',
},
} as DefaultTheme.Config;
import type { DefaultTheme } from 'vitepress';
import nav from './nav';
import sidebar from './sidebar/index';
import socialLinks from './socialLinks';
// https://vitepress.dev/reference/default-theme-config
export default {
logo: '/logo.webp', //logo
//开启本地搜索
search: {
provider: 'local',
},
nav, //头部导航
sidebar, //侧边栏
socialLinks, //项目仓库地址
outlineTitle: '章节导航', // 文章导航提示
docFooter: {
prev: '←上一篇',
next: '下一篇→',
}, //自定义上一篇下一篇按钮文字
lastUpdatedText: '上次更新时间',
//跳转到仓库编辑
editLink: {
text: '在github编辑该页面',
pattern: 'https://github.com/SheenJs/gh-blogs/tree/main/develop/:path',
},
// 底部配置
footer: {
message: '',
copyright: 'Copyright © 2023 YGHHJS',
},
} as DefaultTheme.Config;
sidebar
ts
import { DefaultTheme } from 'vitepress';
import ghui from './ghui';
import css from './css';
import vitepress from './vitepress';
import JavaScript from './JavaScript';
export default {
'/ghui/': ghui,
'/blogs/css/': css,
'/blogs/vitepress/': vitepress,
'/blogs/js/': JavaScript,
} as DefaultTheme.Sidebar;
import { DefaultTheme } from 'vitepress';
import ghui from './ghui';
import css from './css';
import vitepress from './vitepress';
import JavaScript from './JavaScript';
export default {
'/ghui/': ghui,
'/blogs/css/': css,
'/blogs/vitepress/': vitepress,
'/blogs/js/': JavaScript,
} as DefaultTheme.Sidebar;