website/.vitepress/config.js

402 lines
12 KiB
JavaScript

/*
* @LastEditTime: 2024-06-24 00:44:59
* @Description: ...
* @Date: 2023-09-19 19:04:57
* @Author: isboyjc
* @LastEditors: isboyjc
*/
import path from 'path'
import { fileURLToPath } from 'url';
import { defineConfig } from 'vitepress'
// 原子CSS UnoCSS
import UnoCSS from "unocss/vite";
// 组件自动引入
import Components from 'unplugin-vue-components/vite'
// Iconify 解析插件
import Icons from 'unplugin-icons/vite'
// Iconify 自动引入解析器
import IconsResolver from 'unplugin-icons/resolver'
// icon 加载 loader
import { FileSystemIconLoader } from 'unplugin-icons/loaders'
import {description, title, titleEn, descriptionEn, keywords, ico, site, icp, publicSecurityFiling, mail} from './meta'
import {icons} from "./icon"
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const resolve = (dir) => dir ? path.resolve(__dirname, '../', dir) : __dirname
// https://vitepress.dev/reference/site-config
export default defineConfig({
lang: 'zh',
locales: {
root: {
label: '简体中文',
lang: 'zh',
title,
description,
link: '/',
head: [
['meta', { name: 'referrer', content: 'no-referrer-when-downgrade' }],
['meta', { name: 'keywords', content: keywords }],
['meta', { name: 'author', content: 'isboyjc' }],
['meta', { name: 'application-name', content: title }],
['meta', { name: 'apple-mobile-web-app-title', content: title }],
['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'default' }],
['link', { rel: 'shortcut icon', href: ico }],
['link', { rel: 'icon', type: 'image/x-icon', href: ico }],
// ['link', { rel: 'mask-icon', href: '.svg', color: '#06f' }],
// ['meta', { name: 'theme-color', content: '#06f' }],
// webfont
['link', { rel: 'dns-prefetch', href: 'https://fonts.googleapis.com' }],
['link', { rel: 'dns-prefetch', href: 'https://fonts.gstatic.com' }],
['link', { rel: 'preconnect', crossorigin: 'anonymous', href: 'https://fonts.googleapis.com' }],
['link', { rel: 'preconnect', crossorigin: 'anonymous', href: 'https://fonts.gstatic.com' }],
// og
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:description', content: description }],
['meta', { property: 'og:url', content: site }],
['meta', { property: 'og:locale', content: 'zh_CN' }],
],
themeConfig: {
outline: 'deep',
outlineTitle: '目录...',
returnToTopLabel: '返回顶部',
darkModeSwitchLabel: '模式',
sidebarMenuLabel: '归档',
lastUpdatedText:"最后更新时间",
docFooter: {
prev: '上一页',
next: '下一页',
},
nav: [
{ text: '快速了解', link: '/docs/guide' },
{ text: 'API & 扩展', link: '/docs/api/api' },
{ text: '订阅', link: '/docs/setting/subscribe' },
{ text: '联系我们', link: '/docs/team/support' }
],
sidebar: {
'/docs': [
{
text: '公告',
link: '/docs/notice'
},
{
text: '快速了解',
link: '/docs/guide'
},
{
text: '介绍',
items: [
{
text: '记录',
link: '/docs/basic/record'
},
{
text: '编排',
link: '/docs/basic/layout'
},
{
text: '编辑器',
link: '/docs/basic/editor'
},
{
text: '微信录入',
link: '/docs/basic/wechat'
},
{
text: '多级标签',
link: '/docs/basic/label'
},
{
text: '每日回顾',
link: '/docs/basic/review'
},
{
text: '快速搜索',
link: '/docs/basic/search'
},
]
},
{
text: '帐号 & 订阅',
items: [
{
text: '关于订阅',
link: '/docs/setting/subscribe'
},
{
text: '帐号设置',
link: '/docs/setting/account'
},
{
text: '数据迁移',
link: '/docs/setting/transfer'
},
{
text: '用户反馈',
link: '/docs/setting/feedback'
},
]
},
{
text: 'API & 扩展',
items: [
{
text: 'API',
link: '/docs/api/api'
},
{
text: '扩展',
link: '/docs/api/extend'
}
]
},
{
text: '团队',
items: [
{
text: '关于我们',
link: '/docs/team/about'
},
{
text: '联系我们',
link: '/docs/team/support'
}
]
},
{
text: '服务协议',
items: [
{
text: '用户协议',
link: '/docs/other/ua'
},
{
text: '隐私协议',
link: '/docs/other/pa'
}
]
}
]
},
socialLinks: [
{ icon: icons.mail, link: `Mailto:${mail}` }
],
footer: {
psf: publicSecurityFiling,
icp: icp,
},
},
},
en: {
label: 'English',
lang: 'en',
title: titleEn,
description: descriptionEn,
link: '/en/',
head: [
['meta', { name: 'referrer', content: 'no-referrer-when-downgrade' }],
['meta', { name: 'keywords', content: keywords }],
['meta', { name: 'author', content: 'isboyjc' }],
['meta', { name: 'application-name', content: titleEn }],
['meta', { name: 'apple-mobile-web-app-title', content: titleEn }],
['meta', { name: 'apple-mobile-web-app-status-bar-style', content: 'default' }],
['link', { rel: 'shortcut icon', href: ico }],
['link', { rel: 'icon', type: 'image/x-icon', href: ico }],
// ['link', { rel: 'mask-icon', href: '.svg', color: '#06f' }],
// ['meta', { name: 'theme-color', content: '#06f' }],
// webfont
['link', { rel: 'dns-prefetch', href: 'https://fonts.googleapis.com' }],
['link', { rel: 'dns-prefetch', href: 'https://fonts.gstatic.com' }],
['link', { rel: 'preconnect', crossorigin: 'anonymous', href: 'https://fonts.googleapis.com' }],
['link', { rel: 'preconnect', crossorigin: 'anonymous', href: 'https://fonts.gstatic.com' }],
// og
['meta', { property: 'og:type', content: 'website' }],
['meta', { property: 'og:description', content: descriptionEn }],
['meta', { property: 'og:url', content: site }],
['meta', { property: 'og:locale', content: 'zh_CN' }],
],
themeConfig: {
nav: [
{ text: 'Guide', link: '/en/docs/guide' },
{ text: 'API & Extend', link: '/en/docs/api/api' },
{ text: 'Subscribe', link: '/en/docs/setting/subscribe' },
{ text: 'Contact Us', link: '/en/docs/team/support' }
],
sidebar: {
'/en/docs': [
{
text: 'Notice',
link: '/en/docs/notice'
},
{
text: 'Get Guide',
link: '/en/docs/guide'
},
{
text: 'Introduce',
items: [
{
text: 'Record',
link: '/en/docs/basic/record'
},
{
text: 'Layout',
link: '/en/docs/basic/layout'
},
{
text: 'Editor',
link: '/en/docs/basic/editor'
},
{
text: 'WeChat Input',
link: '/en/docs/basic/wechat'
},
{
text: 'Multi Level Tags',
link: '/en/docs/basic/label'
},
{
text: 'Daily Review',
link: '/en/docs/basic/review'
},
{
text: 'Quick Search',
link: '/en/docs/basic/search'
},
]
},
{
text: 'Account & Subscribe',
items: [
{
text: 'About Subscribe',
link: '/en/docs/setting/subscribe'
},
{
text: 'Account Settings',
link: '/en/docs/setting/account'
},
{
text: 'Data Migration ',
link: '/en/docs/setting/transfer'
},
{
text: 'User Feedback',
link: '/en/docs/setting/feedback'
},
]
},
{
text: 'API & Extend',
items: [
{
text: 'API',
link: '/en/docs/api/api'
},
{
text: 'Extend',
link: '/en/docs/api/extend'
}
]
},
{
text: 'Team',
items: [
{
text: 'About Us',
link: '/en/docs/team/about'
},
{
text: 'Contact Us',
link: '/en/docs/team/support'
}
]
},
{
text: 'Service Agreement',
items: [
{
text: 'User Agreement',
link: '/en/docs/other/ua'
},
{
text: 'Privacy Agreement',
link: '/en/docs/other/pa'
}
]
}
]
},
socialLinks: [
{ icon: icons.mail, link: `Mailto:${mail}` }
],
footer: {
psf: publicSecurityFiling,
icp: icp,
},
},
}
},
markdown: {
lineNumbers: true,
},
// vite配置
vite: {
plugins: [
// 插件
Components({
// dirs 指定自动引入组件所在目录位置
dirs: [resolve('.vitepress/theme/components')],
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
resolvers: [
IconsResolver({
prefix: 'icon',
// 默认 iconify 集合别名
// alias: {
// vsci: 'vscode-icons'
// },
customCollections: ['custom']
})
]
}),
Icons({
compiler: 'vue3',
customCollections: {
// custom 图标集, 给svg文件设置fill="currentColor"属性,使图标的颜色具有适应性
custom: FileSystemIconLoader('public/svg/custom', svg => svg.replace(/^<svg /, '<svg fill="currentColor" '))
},
autoInstall: true
}),
UnoCSS({
// 详见 unocss.config.js
})
],
resolve: {
// 替换 Vitepress 内部组件
alias: [
{
find: /^.*\/VPFooter\.vue$/,
replacement: resolve('.vitepress/theme/components/CustomFooter.vue')
}
]
},
},
// 构建完成钩子
async buildEnd(siteConfig) {
// console.log(siteConfig)
// TODO RSS订阅
},
})