You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
live/docusaurus.config.js

173 lines
4.9 KiB
JavaScript

// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
/** @type {import('@docusaurus/types').Config} */
const config = {
title: '浮生绘',
tagline: '人生如梦未醒时,梦如人生我是谁?',
favicon: 'img/favicon.ico',
// Set the production url of your site here
url: 'https://live.aqzscn.cn/',
// Set the /<baseUrl>/ pathname under which your site is served
// For GitHub pages deployment, it is often '/<projectName>/'
baseUrl: '/',
// GitHub pages deployment config.
// If you aren't using GitHub pages, you don't need these.
organizationName: 'gitbobo', // Usually your GitHub org/user name.
projectName: 'live', // Usually your repo name.
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
// Even if you don't use internalization, you can use this field to set useful
// metadata like html lang. For example, if your site is Chinese, you may want
// to replace "en" with "zh-Hans".
i18n: {
defaultLocale: 'zh-Hans',
locales: ['zh-Hans'],
},
themes: [
[
require.resolve("@easyops-cn/docusaurus-search-local"),
/** @type {import("@easyops-cn/docusaurus-search-local").PluginOptions} */
({
// ... Your options.
// `hashed` is recommended as long-term-cache of index file is possible.
hashed: true,
// For Docs using Chinese, The `language` is recommended to set to:
language: ["zh"],
indexBlog: false,
docsRouteBasePath: "/",
}),
],
],
presets: [
[
'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
routeBasePath: '/',
sidebarPath: require.resolve('./sidebars.js'),
editUrl: 'https://git.frp.aqzscn.cn/gitbobo/live/src/branch/main/',
async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) {
const sidebarItems = await defaultSidebarItemsGenerator(args);
return reverseSidebarItems(sidebarItems);
},
showLastUpdateAuthor: true,
showLastUpdateTime: true,
},
// blog: {
// showReadingTime: true,
// // Please change this to your repo.
// // Remove this to remove the "edit this page" links.
// editUrl:
// 'https://github.com/facebook/docusaurus/tree/main/packages/create-docusaurus/templates/shared/',
// },
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
}),
],
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
colorMode: {
respectPrefersColorScheme: true,
},
// Replace with your project's social card
image: 'img/docusaurus-social-card.jpg',
navbar: {
title: '浮生绘',
logo: {
alt: '网站 Logo',
src: 'img/logo.svg',
},
hideOnScroll: true,
items: [
{
type: 'docSidebar',
sidebarId: 'otherSidebar',
label: '杂',
},
{
type: 'docSidebar',
sidebarId: 'newsSidebar',
label: '闻',
},
{
type: 'docSidebar',
sidebarId: 'skillSidebar',
label: '技',
},
{
type: 'docSidebar',
sidebarId: 'mindSidebar',
label: '艺',
},
{
label: 'Gitea',
href: 'https://git.frp.aqzscn.cn/gitbobo/live',
position: 'right',
},
],
},
docs: {
sidebar: {
hideable: true,
autoCollapseCategories: true,
}
},
footer: {
style: 'dark',
copyright: `Copyright © ${new Date().getFullYear()} 浮生绘, 由 Docusaurus 驱动`,
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
additionalLanguages: ['java', 'dart'],
magicComments: [
{
className: 'theme-code-block-highlighted-line',
line: 'highlight-next-line',
block: {start: 'highlight-start', end: 'highlight-end'},
},
{
className: 'code-block-error-line',
line: 'highlight-error-line',
},
]
},
}),
};
function reverseSidebarItems(items, reverse = false) {
// Reverse items in categories
const result = items.map((item) => {
if (item.type === 'category') {
// console.log(item)
const r = item.customProps && item.customProps.reversed
return {...item, items: reverseSidebarItems(item.items, r)};
}
// console.log(item)
return item;
});
// console.log(items)
// Reverse items at current level
if (reverse) {
result.reverse();
}
return result;
}
module.exports = config;