Files
docs/docusaurus.config.js
T

292 lines
7.8 KiB
JavaScript
Raw Normal View History

2023-02-02 23:30:20 -05:00
// @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');
2023-05-22 16:31:34 +08:00
// order usage directory by type first
function sortItemsByCategory(items) {
// type with "category" (directory) first
const sortedItems = items.sort(function(a, b) {
return a.type.localeCompare(b.type);
})
return sortedItems;
}
const renderApiSSR = process.env.API_SSR !== 'false';
2023-07-05 03:54:54 +00:00
const apiConfig = [
'redocusaurus',
{
// Plugin Options for loading OpenAPI files
specs: renderApiSSR ? [
2023-07-05 03:54:54 +00:00
{
spec: 'static/swagger-latest.json',
route: '/api/next/',
},
{
route: '/api/1.20/',
spec: 'static/swagger-20.json',
2023-07-19 13:38:32 -04:00
},
{
route: '/api/1.19/',
spec: 'static/swagger-19.json',
},
2023-07-05 03:54:54 +00:00
]: [],
// Theme Options for modifying how redoc renders them
theme: {
// Change with your site colors
primaryColor: '#1890ff',
},
},
]
const pageConfig = renderApiSSR ? {
2023-07-05 03:54:54 +00:00
exclude: [
'api/**',
],
}: {}
2023-02-02 23:30:20 -05:00
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Gitea Documentation',
tagline: 'Git with a cup of tea',
url: 'https://docs.gitea.com',
baseUrl: '/',
onBrokenLinks: 'warn',
onBrokenMarkdownLinks: 'warn',
favicon: 'img/favicon.png',
2023-08-22 01:27:01 +00:00
plugins: [
[
'docusaurus-plugin-plausible',
{
domain: 'docs.gitea.com',
},
]
],
2023-02-02 23:30:20 -05:00
i18n: {
defaultLocale: 'en-us',
locales: ['en-us', 'zh-cn'/*, 'fr-fr', 'zh-tw'*/], // temporarily disable other locales
2023-05-26 14:30:13 +08:00
localeConfigs: {
'en-us': {
2023-05-26 14:30:13 +08:00
label: 'English',
},
'zh-cn': {
label: '中文',
},
},
2023-02-02 23:30:20 -05:00
},
presets: [
[
'@docusaurus/preset-classic',
//'classic',
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
sidebarPath: require.resolve('./sidebars.js'),
routeBasePath: '/', // Serve the docs at the site's root
editUrl: ({versionDocsDirPath, docPath, locale, version, permalink}) => {
2023-07-31 17:32:28 +00:00
let fileName = `${docPath.replace('.md', '')}.${locale}.md`;
// intro.md has different name from upstream, need to handle this here
if (docPath.includes('intro.md')) {
fileName = `page/index.${locale}.md`;
}
return `https://github.com/go-gitea/gitea/tree/${version === 'current' ? 'main': `release/v${version}`}/docs/content/${fileName}`;
2023-02-02 23:30:20 -05:00
},
versions: {
current: {
2023-06-21 05:30:02 +00:00
label: '1.21-dev', // path is kept as next for dev (so users can always find "nightly" docs)
2023-06-14 07:05:13 +00:00
banner: 'unreleased',
2023-02-02 23:30:20 -05:00
},
2023-06-14 07:05:13 +00:00
'1.20': {
2023-08-21 16:07:00 +00:00
label: '1.20.3'
2023-07-19 13:38:32 -04:00
},
'1.19': {
label: '1.19.4',
2023-03-04 12:34:51 +08:00
}
2023-02-02 23:30:20 -05:00
},
2023-07-19 13:40:14 -04:00
lastVersion: '1.20',
2023-05-22 16:31:34 +08:00
async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) {
const {item} = args;
// Use the provided data to generate a custom sidebar slice
const sidebarItems = await defaultSidebarItemsGenerator(args);
if (item.dirName !== 'usage') {
return sidebarItems;
} else {
return sortItemsByCategory(sidebarItems);
}
},
2023-02-02 23:30:20 -05:00
},
blog: false,
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
2023-07-05 03:54:54 +00:00
pages: pageConfig,
2023-02-02 23:30:20 -05:00
}),
],
2023-07-05 03:54:54 +00:00
apiConfig,
2023-02-02 23:30:20 -05:00
],
themes: [
[
"@easyops-cn/docusaurus-search-local",
{
hashed: false,
2023-05-26 14:30:13 +08:00
language: ["en", "zh"],
2023-02-02 23:30:20 -05:00
highlightSearchTermsOnTargetPage: true,
explicitSearchResultPath: true,
indexBlog: false,
docsRouteBasePath: "/"
}
]
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
colorMode: {
defaultMode: 'light',
2023-05-24 08:44:39 +08:00
disableSwitch: false,
2023-02-02 23:30:20 -05:00
respectPrefersColorScheme: true,
},
announcementBar: {
2023-05-24 04:38:02 +08:00
id: 'announcementBar-3', // Increment on change
content: `This documentation site is fairly new. If you find any issues, please <a target="_blank" rel="noopener noreferrer" href="https://gitea.com/gitea/gitea-docusaurus/issues">let us know</a>. We are currently working on translating the documentation into other languages.`,
2023-02-02 23:30:20 -05:00
},
navbar: {
title: 'Gitea',
logo: {
alt: 'Gitea Logo',
src: 'img/gitea.svg',
href: 'https://about.gitea.com/',
target: '_self',
2023-02-02 23:30:20 -05:00
},
items: [
{
2023-07-05 03:54:54 +00:00
type: 'doc',
docId: 'intro',
2023-02-02 23:30:20 -05:00
position: 'left',
label: 'Docs',
},
2023-07-05 03:54:54 +00:00
{
2023-07-19 13:40:14 -04:00
to: '/api/1.20/',
2023-07-05 03:54:54 +00:00
label: 'API',
position: 'left',
2023-07-19 13:38:32 -04:00
activeBaseRegex: 'api/(1.19|1.20|next)/',
2023-07-05 03:54:54 +00:00
},
{
position: 'left',
label: 'Blog',
href: 'https://blog.gitea.com',
className: 'internal-href',
target: '_self',
},
2023-07-05 03:54:54 +00:00
{
type: 'custom-apiDropdown',
2023-07-05 03:54:54 +00:00
label: 'API Version',
position: 'right',
items: [
{to: '/api/next/', label: '1.21-dev' },
2023-07-19 13:40:14 -04:00
{to: '/api/1.20/', label: '1.20.0' },
2023-07-19 13:38:32 -04:00
{to: '/api/1.19/', label: '1.19.4' },
2023-07-05 03:54:54 +00:00
],
},
2023-02-02 23:30:20 -05:00
{
href: 'https://github.com/go-gitea/gitea',
label: 'Code',
position: 'left',
},
{
type: 'search',
position: 'right',
},
2023-05-26 14:30:13 +08:00
{
2023-04-04 11:14:25 +08:00
type: 'localeDropdown',
position: 'right',
2023-05-26 14:30:13 +08:00
},
2023-02-02 23:30:20 -05:00
{
type: 'docsVersionDropdown',
position: 'right',
dropdownActiveClassDisabled: true,
},
{
2023-07-19 13:57:52 -04:00
to: 'help/support',
2023-02-02 23:30:20 -05:00
position: 'right',
label: 'Support',
2023-07-19 13:57:52 -04:00
activeBaseRegex: 'help/support',
},
{
href: 'https://gitea.com/user/login',
2023-07-19 13:40:14 -04:00
label: 'Sign In',
position: 'right',
className: 'internal-href signin-button',
target: '_self',
},
2023-02-02 23:30:20 -05:00
],
},
footer: {
style: 'dark',
links: [
{
title: 'Community',
items: [
2023-07-21 15:15:51 +00:00
{
label: 'Awesome Gitea',
to: '/awesome',
},
2023-02-02 23:30:20 -05:00
{
label: 'Stack Overflow',
href: 'https://stackoverflow.com/questions/tagged/gitea',
},
{
label: 'Discord',
href: 'https://discord.gg/gitea',
},
2023-07-21 03:51:34 +00:00
{
label: 'Matrix',
href: 'https://matrix.to/#/#gitea-space:matrix.org',
},
{
label: 'Discourse',
href: 'https://discourse.gitea.io/',
},
2023-02-02 23:30:20 -05:00
{
label: 'Twitter',
href: 'https://twitter.com/giteaio',
},
2023-07-21 03:51:34 +00:00
{
label: 'Mastodon',
href: 'https://social.gitea.io/@gitea',
},
2023-02-02 23:30:20 -05:00
],
},
{
2023-07-21 03:51:34 +00:00
title: 'Code',
2023-02-02 23:30:20 -05:00
items: [
{
2023-07-21 03:51:34 +00:00
label: 'GitHub',
2023-02-02 23:30:20 -05:00
href: 'https://github.com/go-gitea/gitea',
},
2023-07-21 03:51:34 +00:00
{
label: 'Gitea',
href: 'https://gitea.com/gitea',
},
2023-07-21 15:15:51 +00:00
{
label: 'Tea CLI',
href: 'https://gitea.com/gitea/tea',
},
2023-02-02 23:30:20 -05:00
],
},
],
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},
}),
};
module.exports = config;