kubernetes-guide/docusaurus.config.ts

299 lines
9.3 KiB
TypeScript
Raw Normal View History

2023-11-28 16:32:21 +08:00
import PrismDark from './src/utils/prismDark';
import type { Config } from '@docusaurus/types';
// import { themes as prismThemes } from 'prism-react-renderer';
2023-10-13 13:37:29 +08:00
2023-10-13 17:59:36 +08:00
const beian = '蜀ICP备2021009081号-1'
2023-11-28 16:32:21 +08:00
const config: Config = {
2023-10-13 13:37:29 +08:00
title: 'Kubernetes 实践指南', // 网站标题
tagline: '云原生老司机带你飞', // slogan
favicon: 'img/logo.svg', // 电子书 favicon 文件,注意替换
url: 'https://imroc.cc', // 在线电子书的 url
2023-10-13 16:26:33 +08:00
baseUrl: '/kubernetes/', // 在线电子书所在 url 的路径,如果没有子路径,可改为 "/"
2023-10-13 13:37:29 +08:00
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'imroc', // GitHub 的 org/user 名称
projectName: 'kubernetes-guide', // Github repo 名称
onBrokenLinks: 'warn', // 避免路径引用错误导致编译失败
onBrokenMarkdownLinks: 'warn',
i18n: {
// 默认语言用中文
defaultLocale: 'zh-CN',
// 不需要多语言支持的话,就只填中文
locales: ['zh-CN'],
},
plugins: [
'docusaurus-plugin-sass', // 启用 sass 插件,支持 scss
2023-10-13 16:58:47 +08:00
'plugin-image-zoom',
[
'@docusaurus/plugin-ideal-image',
{
disableInDev: false,
},
],
[
'@docusaurus/plugin-pwa',
{
debug: false,
offlineModeActivationStrategies: [
'appInstalled',
'standalone',
'queryString',
],
pwaHead: [
{ tagName: 'link', rel: 'icon', href: '/img/logo.png' },
{ tagName: 'link', rel: 'manifest', href: '/manifest.json' },
{ tagName: 'meta', name: 'theme-color', content: '#12affa' },
],
},
],
2023-10-13 13:37:29 +08:00
[
/** @type {import('@docusaurus/plugin-content-docs').PluginOptions} */
'@docusaurus/plugin-content-docs',
({
2024-04-10 16:24:23 +08:00
id: 'basics',
path: 'content/basics',
2024-04-25 10:04:39 +08:00
showLastUpdateTime: true,
2023-10-13 13:37:29 +08:00
// 文档的路由前缀
2024-04-10 16:24:23 +08:00
routeBasePath: '/basics',
2023-10-13 13:37:29 +08:00
// 左侧导航栏的配置
2024-04-10 16:24:23 +08:00
sidebarPath: require.resolve('./content/basics/sidebars.ts'),
2023-10-13 13:37:29 +08:00
// 每个文档左下角 "编辑此页" 的链接
editUrl: ({ docPath }) =>
2024-04-10 16:24:23 +08:00
`https://github.com/imroc/kubernetes-guide/edit/main/content/basics/${docPath}`,
}),
],
2024-04-23 16:48:27 +08:00
[
/** @type {import('@docusaurus/plugin-content-docs').PluginOptions} */
'@docusaurus/plugin-content-docs',
({
id: 'monitornig',
path: 'content/monitoring',
2024-04-25 10:04:39 +08:00
showLastUpdateTime: true,
2024-04-23 16:48:27 +08:00
// 文档的路由前缀
routeBasePath: '/monitoring',
// 左侧导航栏的配置
sidebarPath: require.resolve('./content/monitoring/sidebars.ts'),
// 每个文档左下角 "编辑此页" 的链接
editUrl: ({ docPath }) =>
`https://github.com/imroc/kubernetes-guide/edit/main/content/monitoring/${docPath}`,
}),
],
2024-04-10 16:24:23 +08:00
[
/** @type {import('@docusaurus/plugin-content-docs').PluginOptions} */
'@docusaurus/plugin-content-docs',
({
id: 'best-practices',
path: 'content/best-practices',
2024-04-25 10:04:39 +08:00
showLastUpdateTime: true,
2024-04-10 16:24:23 +08:00
// 文档的路由前缀
routeBasePath: '/best-practices',
// 左侧导航栏的配置
sidebarPath: require.resolve('./content/best-practices/sidebars.ts'),
// 每个文档左下角 "编辑此页" 的链接
editUrl: ({ docPath }) =>
`https://github.com/imroc/kubernetes-guide/edit/main/content/best-practices/${docPath}`,
}),
],
[
/** @type {import('@docusaurus/plugin-content-docs').PluginOptions} */
'@docusaurus/plugin-content-docs',
({
id: 'cases',
path: 'content/cases',
2024-04-25 10:04:39 +08:00
showLastUpdateTime: true,
2024-04-10 16:24:23 +08:00
// 文档的路由前缀
routeBasePath: '/cases',
// 左侧导航栏的配置
sidebarPath: require.resolve('./content/cases/sidebars.ts'),
// 每个文档左下角 "编辑此页" 的链接
editUrl: ({ docPath }) =>
`https://github.com/imroc/kubernetes-guide/edit/main/content/cases/${docPath}`,
}),
],
[
/** @type {import('@docusaurus/plugin-content-docs').PluginOptions} */
'@docusaurus/plugin-content-docs',
({
id: 'appendix',
path: 'content/appendix',
2024-04-25 10:04:39 +08:00
showLastUpdateTime: true,
2024-04-10 16:24:23 +08:00
// 文档的路由前缀
routeBasePath: '/appendix',
// 左侧导航栏的配置
sidebarPath: require.resolve('./content/appendix/sidebars.ts'),
// 每个文档左下角 "编辑此页" 的链接
editUrl: ({ docPath }) =>
`https://github.com/imroc/kubernetes-guide/edit/main/content/appendix/${docPath}`,
2023-10-13 13:37:29 +08:00
}),
],
],
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: false, // 禁用 preset 默认的 docs直接用 plugin-content-docs 配置可以更灵活。
blog: false, // 禁用博客
theme: {
customCss: require.resolve('./src/css/custom.scss'), // custom.css 重命名为 custom.scss
},
}),
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
// algolia 搜索功能
2023-10-14 08:32:12 +08:00
algolia: {
appId: '7WGNV6HFP7',
2023-10-14 14:11:27 +08:00
apiKey: 'f3bd4ef4fa5dbfa7494fc901311e584d',
2023-10-14 08:50:17 +08:00
indexName: 'imroc-kubernetes',
2023-10-14 14:20:38 +08:00
contextualSearch: false,
2023-10-14 08:32:12 +08:00
},
2023-10-13 13:37:29 +08:00
// giscus 评论功能
giscus: {
repo: 'imroc/kubernetes-guide',
repoId: 'R_kgDOG-4vhA',
category: 'General',
categoryId: 'DIC_kwDOG-4vhM4COPpN',
},
navbar: {
title: 'Kuberntes 实践指南', // 左上角的电子书名称
logo: {
alt: 'Kubernetes',
src: 'img/logo.svg', // 电子书 logo 文件,注意替换
},
items: [
2024-04-10 16:24:23 +08:00
{
label: '基础实践',
2024-05-10 12:03:18 +08:00
position: 'left',
2024-04-10 16:24:23 +08:00
to: '/basics',
2024-04-23 16:50:40 +08:00
},
{
2024-04-23 16:48:27 +08:00
label: '监控告警',
2024-05-10 12:03:18 +08:00
position: 'left',
2024-04-23 16:48:27 +08:00
to: '/monitoring',
2024-04-10 16:24:23 +08:00
},
{
label: '最佳实践',
2024-05-10 12:03:18 +08:00
position: 'left',
2024-04-10 16:24:23 +08:00
to: '/best-practices',
},
2024-04-11 10:16:32 +08:00
{
label: '实践案例',
2024-05-10 12:03:18 +08:00
position: 'left',
2024-04-11 10:16:32 +08:00
to: '/cases',
},
2024-04-10 16:24:23 +08:00
{
2024-04-12 16:19:37 +08:00
label: '附录',
2024-05-10 12:03:18 +08:00
position: 'left',
2024-04-12 16:19:37 +08:00
to: '/appendix',
2024-04-11 10:11:23 +08:00
},
2024-04-10 16:24:23 +08:00
{
2024-04-12 16:19:37 +08:00
label: 'Kubernetes 排障指南',
2024-04-10 16:24:23 +08:00
position: 'right',
2024-04-20 09:53:52 +08:00
href: 'https://imroc.cc/kubernetes-troubleshooting',
},
{
label: 'TKE 实践指南',
position: 'right',
href: 'https://imroc.cc/tke',
},
{
label: 'istio 实践指南',
position: 'right',
href: 'https://imroc.cc/istio',
2024-04-10 16:24:23 +08:00
},
2023-10-13 13:37:29 +08:00
{
2023-11-28 16:32:21 +08:00
href: 'https://github.com/imroc/kubernetes-guide', // 改成自己的仓库地址
2023-10-13 13:37:29 +08:00
label: 'GitHub',
position: 'right',
},
],
},
// 自定义页脚
footer: {
style: 'dark',
links: [
{
title: '相关电子书',
items: [
2024-04-12 16:19:37 +08:00
{
label: 'Kubernetes 排障指南',
2024-04-20 09:53:52 +08:00
href: 'https://imroc.cc/kubernetes-troubleshooting',
2024-04-12 16:19:37 +08:00
},
2023-10-13 13:37:29 +08:00
{
label: 'istio 实践指南',
href: 'https://imroc.cc/istio',
},
2024-01-25 20:51:47 +08:00
{
label: 'TKE 实践指南',
href: 'https://imroc.cc/tke',
},
2023-10-13 13:37:29 +08:00
],
},
{
title: '更多',
items: [
{
label: 'roc 云原生',
href: 'https://imroc.cc',
},
{
label: 'GitHub',
href: 'https://github.com/imroc/kubernetes-guide',
},
],
},
],
2023-10-13 17:59:36 +08:00
copyright: `Copyright ${new Date().getFullYear()} roc | All Right Reserved | <a href="http://beian.miit.gov.cn/">${beian}</a>`,
2023-10-13 13:37:29 +08:00
},
// 自定义代码高亮
prism: {
2023-11-28 16:32:21 +08:00
theme: PrismDark,
2023-10-13 13:37:29 +08:00
magicComments: [
{
className: 'code-block-highlighted-line',
line: 'highlight-next-line',
block: { start: 'highlight-start', end: 'highlight-end' }
},
{
className: 'code-block-add-line',
line: 'highlight-add-line',
block: { start: 'highlight-add-start', end: 'highlight-add-end' }
},
{
className: 'code-block-update-line',
line: 'highlight-update-line',
block: { start: 'highlight-update-start', end: 'highlight-update-end' }
},
{
className: 'code-block-error-line',
line: 'highlight-error-line',
block: { start: 'highlight-error-start', end: 'highlight-error-end' }
},
],
// languages enabled by default: https://github.com/FormidableLabs/prism-react-renderer/blob/master/packages/generate-prism-languages/index.ts#L9-L23
// prism supported languages: https://prismjs.com/#supported-languages
additionalLanguages: [
'java',
'json',
'hcl',
2023-11-28 16:42:35 +08:00
'bash',
'diff',
2024-04-23 16:39:24 +08:00
'docker',
2023-10-13 13:37:29 +08:00
],
},
}),
};
2023-11-28 16:32:21 +08:00
export default config;