axios-miniprogram/docs/.vitepress/config.ts

208 lines
5.9 KiB
TypeScript
Raw Permalink Normal View History

2023-03-24 22:35:58 +08:00
import { defineConfig } from 'vitepress';
2023-04-11 22:09:29 +08:00
import { VitePWA } from 'vite-plugin-pwa';
2023-04-16 00:01:40 +08:00
import { linkIntro } from './utils/link-intro';
2023-04-12 17:36:05 +08:00
2023-04-16 00:01:40 +08:00
linkIntro();
2023-03-24 22:35:58 +08:00
// https://vitepress.dev/reference/site-config
export default defineConfig({
title: 'axios-miniprogram',
2023-04-12 17:36:05 +08:00
titleTemplate: ':title - axios',
2023-03-24 22:35:58 +08:00
description: '基于 Promise 的 HTTP 请求库,适用于各大小程序平台。',
2023-04-11 16:10:23 +08:00
srcDir: 'pages',
2023-04-14 23:15:49 +08:00
lastUpdated: true,
2023-04-15 16:21:54 +08:00
cleanUrls: true,
2023-04-13 14:16:11 +08:00
2023-04-12 17:36:05 +08:00
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
2023-04-15 10:29:56 +08:00
2023-04-12 17:36:05 +08:00
nav: [
2023-04-15 16:21:54 +08:00
{ text: '指南', link: '/guide/intro', activeMatch: '/guide/' },
2023-04-19 21:36:06 +08:00
{ text: '入门', link: '/basics/request', activeMatch: '/basics/' },
2023-04-16 00:01:40 +08:00
{
2023-04-19 21:36:06 +08:00
text: '进阶',
2023-05-08 15:57:18 +08:00
link: '/advanced/middleware',
2023-04-16 00:01:40 +08:00
activeMatch: '/advanced/',
},
2023-04-12 17:36:05 +08:00
],
2023-04-15 10:29:56 +08:00
sidebar: sidebar(),
2023-04-12 17:36:05 +08:00
socialLinks: [
2023-08-12 15:48:36 +08:00
{
icon: 'github',
link: 'https://github.com/zjxxxxxxxxx/axios-miniprogram',
},
2023-04-12 17:36:05 +08:00
],
2023-04-14 23:15:49 +08:00
editLink: {
2023-04-15 10:29:56 +08:00
pattern: ({ relativePath }) => {
2023-04-18 11:23:27 +08:00
if (relativePath.endsWith('/intro.md')) {
2023-08-12 15:48:36 +08:00
return 'https://github.com/zjxxxxxxxxx/axios-miniprogram/edit/main/README.md';
2023-04-15 10:29:56 +08:00
}
2023-08-12 15:48:36 +08:00
return `https://github.com/zjxxxxxxxxx/axios-miniprogram/edit/main/docs/pages/${relativePath}`;
2023-04-15 10:29:56 +08:00
},
2023-04-14 23:15:49 +08:00
text: '在 GitHub 上编辑此页面',
},
2023-04-15 10:29:56 +08:00
algolia: algolia(),
2023-04-12 17:36:05 +08:00
returnToTopLabel: '返回顶部',
2023-04-17 14:12:52 +08:00
outlineTitle: '导航',
2023-04-12 17:36:05 +08:00
darkModeSwitchLabel: '主题',
2023-04-13 14:16:11 +08:00
sidebarMenuLabel: '菜单',
2023-04-14 23:15:49 +08:00
lastUpdatedText: '最后一次更新',
2023-04-13 14:16:11 +08:00
docFooter: {
prev: '上一页',
next: '下一页',
},
2023-04-12 17:36:05 +08:00
footer: {
message:
2023-08-12 15:48:36 +08:00
'根据 <a href="https://github.com/zjxxxxxxxxx/axios-miniprogram/blob/main/LICENSE">MIT License</a> 发布',
2023-04-12 17:36:05 +08:00
copyright:
2023-08-12 15:48:36 +08:00
'Copyright © 2020-至今 <a href="https://github.com/zjxxxxxxxxx">zjxxxxxxxxx</a>',
2023-04-12 17:36:05 +08:00
},
},
2023-04-13 14:16:11 +08:00
markdown: {
theme: {
light: 'github-light',
dark: 'github-dark',
},
},
2023-04-11 22:09:29 +08:00
vite: {
plugins: [
VitePWA({
outDir: '.vitepress/dist',
manifest: {
name: 'axios-miniprogram',
short_name: 'axios',
theme_color: '#ffffff',
icons: [],
},
}),
2023-03-24 22:35:58 +08:00
],
},
});
2023-04-15 10:29:56 +08:00
function sidebar() {
return [
{
text: '指南',
items: [
2023-04-15 16:21:54 +08:00
{ text: '简介', link: '/guide/intro' },
{ text: '开始', link: '/guide/quick-start' },
2023-04-15 10:29:56 +08:00
],
},
2023-04-19 21:36:06 +08:00
2023-04-15 10:29:56 +08:00
{
2023-04-19 21:36:06 +08:00
text: '入门',
2023-04-15 10:29:56 +08:00
items: [
2023-04-15 16:21:54 +08:00
{ text: '发送请求', link: '/basics/request' },
2023-04-19 21:36:06 +08:00
{ text: '响应体', link: '/basics/response' },
{ text: '错误处理', link: '/basics/error-handler' },
2023-04-16 21:18:04 +08:00
{ text: '动态地址', link: '/basics/dynamic-url' },
2023-04-19 21:36:06 +08:00
{ text: '请求配置', link: '/basics/config' },
{ text: '默认配置', link: '/basics/defaults' },
2023-04-16 21:18:04 +08:00
{ text: '参数系列化', link: '/basics/params-serializer' },
{ text: '转换数据', link: '/basics/transform-data' },
2023-04-15 16:21:54 +08:00
{ text: '下载文件', link: '/basics/download' },
2023-04-18 11:14:57 +08:00
{ text: '上传文件', link: '/basics/upload' },
2023-04-16 00:01:40 +08:00
],
collapsed: false,
2023-04-16 00:01:40 +08:00
},
2023-04-19 21:36:06 +08:00
2023-04-16 00:01:40 +08:00
{
2023-04-19 21:36:06 +08:00
text: '进阶',
2023-04-16 00:01:40 +08:00
items: [
2023-04-25 23:02:05 +08:00
{ text: '中间件', link: '/advanced/middleware' },
2023-04-16 00:01:40 +08:00
{ text: '请求拦截器', link: '/advanced/request-interceptor' },
{ text: '响应拦截器', link: '/advanced/response-interceptor' },
2023-04-19 21:36:06 +08:00
{ text: '取消请求', link: '/advanced/cancel' },
2023-04-16 00:01:40 +08:00
{ text: '创建实例', link: '/advanced/instance' },
2023-04-25 23:02:05 +08:00
{ text: '扩展实例', link: '/advanced/extend' },
2023-04-16 21:18:04 +08:00
{ text: '平台适配器', link: '/advanced/adapter' },
2023-04-15 10:29:56 +08:00
],
collapsed: false,
2023-04-15 10:29:56 +08:00
},
2023-04-16 00:01:40 +08:00
2023-04-19 21:36:06 +08:00
{
text: '请求方法',
items: [
{ text: 'OPTIONS', link: '/method/OPTIONS' },
{ text: 'GET', link: '/method/GET' },
{ text: 'HEAD', link: '/method/HEAD' },
{ text: 'POST', link: '/method/POST' },
{ text: 'PUT', link: '/method/PUT' },
{ text: 'PATCH', link: '/method/PATCH' },
{ text: 'DELETE', link: '/method/DELETE' },
{ text: 'TRACE', link: '/method/TRACE' },
{ text: 'CONNECT', link: '/method/CONNECT' },
],
collapsed: false,
},
2023-04-15 10:29:56 +08:00
{
text: '致贡献者',
items: [
{
text: '行为准则',
2023-08-12 15:48:36 +08:00
link: 'https://github.com/zjxxxxxxxxx/axios-miniprogram/blob/main/CODE_OF_CONDUCT.md',
2023-04-15 10:29:56 +08:00
},
{
text: '贡献指南',
2023-08-12 15:48:36 +08:00
link: 'https://github.com/zjxxxxxxxxx/axios-miniprogram/blob/main/CONTRIBUTING.md',
2023-04-15 10:29:56 +08:00
},
],
},
];
}
function algolia() {
return {
appId: 'B2V3TSSQ2T',
2023-04-19 22:52:35 +08:00
apiKey: '2eddc4539ada25bf664eddcb91930736',
2023-04-15 10:29:56 +08:00
indexName: 'axios-miniprogram',
placeholder: '搜索文档',
translations: {
button: {
buttonText: '搜索文档',
buttonAriaLabel: '搜索文档',
},
modal: {
searchBox: {
resetButtonTitle: '清除查询条件',
resetButtonAriaLabel: '清除查询条件',
cancelButtonText: '取消',
cancelButtonAriaLabel: '取消',
},
startScreen: {
recentSearchesTitle: '搜索历史',
noRecentSearchesText: '没有搜索历史',
saveRecentSearchButtonTitle: '保存至搜索历史',
removeRecentSearchButtonTitle: '从搜索历史中移除',
favoriteSearchesTitle: '收藏',
removeFavoriteSearchButtonTitle: '从收藏中移除',
},
errorScreen: {
titleText: '无法获取结果',
helpText: '你可能需要检查你的网络连接',
},
footer: {
selectText: '选择',
navigateText: '切换',
closeText: '关闭',
searchByText: '搜索提供者',
},
noResultsScreen: {
noResultsText: '无法找到相关结果',
suggestedQueryText: '你可以尝试查询',
reportMissingResultsText: '你认为该查询应该有结果?',
reportMissingResultsLinkText: '点击反馈',
},
},
},
};
}