mirror of
https://gitea.com/gitea/docs.git
synced 2026-09-17 19:55:34 +00:00
Update docusaurus.config.js
This commit is contained in:
+301
-301
@@ -1,301 +1,301 @@
|
|||||||
// @ts-check
|
// @ts-check
|
||||||
// Note: type annotations allow type checking and IDEs autocompletion
|
// Note: type annotations allow type checking and IDEs autocompletion
|
||||||
|
|
||||||
import {themes as prismThemes} from 'prism-react-renderer';
|
import {themes as prismThemes} from 'prism-react-renderer';
|
||||||
|
|
||||||
const lightCodeTheme = prismThemes.github;
|
const lightCodeTheme = prismThemes.github;
|
||||||
const darkCodeTheme = prismThemes.dracula;
|
const darkCodeTheme = prismThemes.dracula;
|
||||||
|
|
||||||
// order usage directory by type first
|
// order usage directory by type first
|
||||||
function sortItemsByCategory(items) {
|
function sortItemsByCategory(items) {
|
||||||
// type with "category" (directory) first
|
// type with "category" (directory) first
|
||||||
const sortedItems = items.sort(function(a, b) {
|
const sortedItems = items.sort(function(a, b) {
|
||||||
return a.type.localeCompare(b.type);
|
return a.type.localeCompare(b.type);
|
||||||
})
|
})
|
||||||
return sortedItems;
|
return sortedItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderApiSSR = process.env.API_SSR !== 'false';
|
const renderApiSSR = process.env.API_SSR !== 'false';
|
||||||
|
|
||||||
const apiConfig = [
|
const apiConfig = [
|
||||||
'redocusaurus',
|
'redocusaurus',
|
||||||
{
|
{
|
||||||
// Plugin Options for loading OpenAPI files
|
// Plugin Options for loading OpenAPI files
|
||||||
specs: renderApiSSR ? [
|
specs: renderApiSSR ? [
|
||||||
{
|
{
|
||||||
spec: 'static/swagger-latest.json',
|
spec: 'static/swagger-latest.json',
|
||||||
route: '/api/next/',
|
route: '/api/next/',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
route: '/api/1.21/',
|
route: '/api/1.21/',
|
||||||
spec: 'static/swagger-21.json',
|
spec: 'static/swagger-21.json',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
route: '/api/1.20/',
|
route: '/api/1.20/',
|
||||||
spec: 'static/swagger-20.json',
|
spec: 'static/swagger-20.json',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
route: '/api/1.19/',
|
route: '/api/1.19/',
|
||||||
spec: 'static/swagger-19.json',
|
spec: 'static/swagger-19.json',
|
||||||
},
|
},
|
||||||
]: [],
|
]: [],
|
||||||
// Theme Options for modifying how redoc renders them
|
// Theme Options for modifying how redoc renders them
|
||||||
theme: {
|
theme: {
|
||||||
// Change with your site colors
|
// Change with your site colors
|
||||||
primaryColor: '#1890ff',
|
primaryColor: '#1890ff',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const pageConfig = renderApiSSR ? {
|
const pageConfig = renderApiSSR ? {
|
||||||
exclude: [
|
exclude: [
|
||||||
'api/**',
|
'api/**',
|
||||||
],
|
],
|
||||||
}: {}
|
}: {}
|
||||||
|
|
||||||
/** @type {import('@docusaurus/types').Config} */
|
/** @type {import('@docusaurus/types').Config} */
|
||||||
const config = {
|
const config = {
|
||||||
title: 'Gitea Documentation',
|
title: 'Gitea Documentation',
|
||||||
tagline: 'Git with a cup of tea',
|
tagline: 'Git with a cup of tea',
|
||||||
url: 'https://docs.gitea.com',
|
url: 'https://docs.gitea.com',
|
||||||
baseUrl: '/',
|
baseUrl: '/',
|
||||||
onBrokenLinks: 'warn',
|
onBrokenLinks: 'warn',
|
||||||
onBrokenMarkdownLinks: 'warn',
|
onBrokenMarkdownLinks: 'warn',
|
||||||
favicon: 'img/favicon.png',
|
favicon: 'img/favicon.png',
|
||||||
|
|
||||||
plugins: [
|
plugins: [
|
||||||
[
|
[
|
||||||
'docusaurus-plugin-plausible',
|
'docusaurus-plugin-plausible',
|
||||||
{
|
{
|
||||||
domain: 'docs.gitea.com',
|
domain: 'docs.gitea.com',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
i18n: {
|
i18n: {
|
||||||
defaultLocale: 'en-us',
|
defaultLocale: 'en-us',
|
||||||
locales: ['en-us', 'zh-cn'/*, 'fr-fr', 'zh-tw'*/], // temporarily disable other locales
|
locales: ['en-us', 'zh-cn'/*, 'fr-fr', 'zh-tw'*/], // temporarily disable other locales
|
||||||
localeConfigs: {
|
localeConfigs: {
|
||||||
'en-us': {
|
'en-us': {
|
||||||
label: 'English',
|
label: 'English',
|
||||||
},
|
},
|
||||||
'zh-cn': {
|
'zh-cn': {
|
||||||
label: '中文',
|
label: '中文',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
presets: [
|
presets: [
|
||||||
[
|
[
|
||||||
'@docusaurus/preset-classic',
|
'@docusaurus/preset-classic',
|
||||||
//'classic',
|
//'classic',
|
||||||
/** @type {import('@docusaurus/preset-classic').Options} */
|
/** @type {import('@docusaurus/preset-classic').Options} */
|
||||||
({
|
({
|
||||||
docs: {
|
docs: {
|
||||||
sidebarPath: require.resolve('./sidebars.js'),
|
sidebarPath: require.resolve('./sidebars.js'),
|
||||||
routeBasePath: '/', // Serve the docs at the site's root
|
routeBasePath: '/', // Serve the docs at the site's root
|
||||||
editUrl: ({versionDocsDirPath, docPath, locale, version, permalink}) => {
|
editUrl: ({versionDocsDirPath, docPath, locale, version, permalink}) => {
|
||||||
let fileName = `${docPath.replace('.md', '')}.${locale}.md`;
|
let fileName = `${docPath.replace('.md', '')}.${locale}.md`;
|
||||||
// intro.md has different name from upstream, need to handle this here
|
// intro.md has different name from upstream, need to handle this here
|
||||||
if (docPath.includes('intro.md')) {
|
if (docPath.includes('intro.md')) {
|
||||||
fileName = `page/index.${locale}.md`;
|
fileName = `page/index.${locale}.md`;
|
||||||
}
|
}
|
||||||
return `https://github.com/go-gitea/gitea/tree/${version === 'current' ? 'main': `release/v${version}`}/docs/content/${fileName}`;
|
return `https://github.com/go-gitea/gitea/tree/${version === 'current' ? 'main': `release/v${version}`}/docs/content/${fileName}`;
|
||||||
},
|
},
|
||||||
versions: {
|
versions: {
|
||||||
current: {
|
current: {
|
||||||
label: '1.22-dev', // path is kept as next for dev (so users can always find "nightly" docs)
|
label: '1.22-dev', // path is kept as next for dev (so users can always find "nightly" docs)
|
||||||
banner: 'unreleased',
|
banner: 'unreleased',
|
||||||
},
|
},
|
||||||
'1.21': {
|
'1.21': {
|
||||||
label: '1.21.0',
|
label: '1.21.1',
|
||||||
},
|
},
|
||||||
'1.20': {
|
'1.20': {
|
||||||
label: '1.20.5'
|
label: '1.20.5'
|
||||||
},
|
},
|
||||||
'1.19': {
|
'1.19': {
|
||||||
label: '1.19.4',
|
label: '1.19.4',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
lastVersion: '1.21',
|
lastVersion: '1.21',
|
||||||
async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) {
|
async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) {
|
||||||
const {item} = args;
|
const {item} = args;
|
||||||
// Use the provided data to generate a custom sidebar slice
|
// Use the provided data to generate a custom sidebar slice
|
||||||
const sidebarItems = await defaultSidebarItemsGenerator(args);
|
const sidebarItems = await defaultSidebarItemsGenerator(args);
|
||||||
if (item.dirName !== 'usage') {
|
if (item.dirName !== 'usage') {
|
||||||
return sidebarItems;
|
return sidebarItems;
|
||||||
} else {
|
} else {
|
||||||
return sortItemsByCategory(sidebarItems);
|
return sortItemsByCategory(sidebarItems);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
blog: false,
|
blog: false,
|
||||||
theme: {
|
theme: {
|
||||||
customCss: require.resolve('./src/css/custom.css'),
|
customCss: require.resolve('./src/css/custom.css'),
|
||||||
},
|
},
|
||||||
pages: pageConfig,
|
pages: pageConfig,
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
apiConfig,
|
apiConfig,
|
||||||
],
|
],
|
||||||
themes: [
|
themes: [
|
||||||
[
|
[
|
||||||
"@easyops-cn/docusaurus-search-local",
|
"@easyops-cn/docusaurus-search-local",
|
||||||
{
|
{
|
||||||
hashed: false,
|
hashed: false,
|
||||||
language: ["en", "zh"],
|
language: ["en", "zh"],
|
||||||
highlightSearchTermsOnTargetPage: true,
|
highlightSearchTermsOnTargetPage: true,
|
||||||
explicitSearchResultPath: true,
|
explicitSearchResultPath: true,
|
||||||
indexBlog: false,
|
indexBlog: false,
|
||||||
docsRouteBasePath: "/"
|
docsRouteBasePath: "/"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
themeConfig:
|
themeConfig:
|
||||||
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
|
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
|
||||||
({
|
({
|
||||||
colorMode: {
|
colorMode: {
|
||||||
defaultMode: 'light',
|
defaultMode: 'light',
|
||||||
disableSwitch: false,
|
disableSwitch: false,
|
||||||
respectPrefersColorScheme: true,
|
respectPrefersColorScheme: true,
|
||||||
},
|
},
|
||||||
//announcementBar: {
|
//announcementBar: {
|
||||||
// id: 'announcementBar-3', // Increment on change
|
// 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.`,
|
// 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.`,
|
||||||
//},
|
//},
|
||||||
navbar: {
|
navbar: {
|
||||||
title: 'Gitea',
|
title: 'Gitea',
|
||||||
logo: {
|
logo: {
|
||||||
alt: 'Gitea Logo',
|
alt: 'Gitea Logo',
|
||||||
src: 'img/gitea.svg',
|
src: 'img/gitea.svg',
|
||||||
href: 'https://about.gitea.com/',
|
href: 'https://about.gitea.com/',
|
||||||
target: '_self',
|
target: '_self',
|
||||||
},
|
},
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
type: 'doc',
|
type: 'doc',
|
||||||
docId: 'intro',
|
docId: 'intro',
|
||||||
position: 'left',
|
position: 'left',
|
||||||
label: 'Docs',
|
label: 'Docs',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
to: '/api/1.20/',
|
to: '/api/1.20/',
|
||||||
label: 'API',
|
label: 'API',
|
||||||
position: 'left',
|
position: 'left',
|
||||||
activeBaseRegex: 'api/(1.19|1.20|1.21|next)/',
|
activeBaseRegex: 'api/(1.19|1.20|1.21|next)/',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
position: 'left',
|
position: 'left',
|
||||||
label: 'Blog',
|
label: 'Blog',
|
||||||
href: 'https://blog.gitea.com',
|
href: 'https://blog.gitea.com',
|
||||||
className: 'internal-href',
|
className: 'internal-href',
|
||||||
target: '_self',
|
target: '_self',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'custom-apiDropdown',
|
type: 'custom-apiDropdown',
|
||||||
label: 'API Version',
|
label: 'API Version',
|
||||||
position: 'right',
|
position: 'right',
|
||||||
items: [
|
items: [
|
||||||
{to: '/api/next/', label: '1.22-dev' },
|
{to: '/api/next/', label: '1.22-dev' },
|
||||||
{to: '/api/1.21/', label: '1.21.0' },
|
{to: '/api/1.21/', label: '1.21.1' },
|
||||||
{to: '/api/1.20/', label: '1.20.4' },
|
{to: '/api/1.20/', label: '1.20.4' },
|
||||||
{to: '/api/1.19/', label: '1.19.4' },
|
{to: '/api/1.19/', label: '1.19.4' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: 'https://github.com/go-gitea/gitea',
|
href: 'https://github.com/go-gitea/gitea',
|
||||||
label: 'Code',
|
label: 'Code',
|
||||||
position: 'left',
|
position: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'search',
|
type: 'search',
|
||||||
position: 'right',
|
position: 'right',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'localeDropdown',
|
type: 'localeDropdown',
|
||||||
position: 'right',
|
position: 'right',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'docsVersionDropdown',
|
type: 'docsVersionDropdown',
|
||||||
position: 'right',
|
position: 'right',
|
||||||
dropdownActiveClassDisabled: true,
|
dropdownActiveClassDisabled: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
to: 'help/support',
|
to: 'help/support',
|
||||||
position: 'right',
|
position: 'right',
|
||||||
label: 'Support',
|
label: 'Support',
|
||||||
activeBaseRegex: 'help/support',
|
activeBaseRegex: 'help/support',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
href: 'https://gitea.com/user/login',
|
href: 'https://gitea.com/user/login',
|
||||||
label: 'Sign In',
|
label: 'Sign In',
|
||||||
position: 'right',
|
position: 'right',
|
||||||
className: 'internal-href signin-button',
|
className: 'internal-href signin-button',
|
||||||
target: '_self',
|
target: '_self',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
style: 'dark',
|
style: 'dark',
|
||||||
links: [
|
links: [
|
||||||
{
|
{
|
||||||
title: 'Community',
|
title: 'Community',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
label: 'Awesome Gitea',
|
label: 'Awesome Gitea',
|
||||||
to: '/awesome',
|
to: '/awesome',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Stack Overflow',
|
label: 'Stack Overflow',
|
||||||
href: 'https://stackoverflow.com/questions/tagged/gitea',
|
href: 'https://stackoverflow.com/questions/tagged/gitea',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Discord',
|
label: 'Discord',
|
||||||
href: 'https://discord.gg/gitea',
|
href: 'https://discord.gg/gitea',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Matrix',
|
label: 'Matrix',
|
||||||
href: 'https://matrix.to/#/#gitea-space:matrix.org',
|
href: 'https://matrix.to/#/#gitea-space:matrix.org',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Forum',
|
label: 'Forum',
|
||||||
href: 'https://forum.gitea.com/',
|
href: 'https://forum.gitea.com/',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Twitter',
|
label: 'Twitter',
|
||||||
href: 'https://twitter.com/giteaio',
|
href: 'https://twitter.com/giteaio',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Mastodon',
|
label: 'Mastodon',
|
||||||
href: 'https://social.gitea.io/@gitea',
|
href: 'https://social.gitea.io/@gitea',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Code',
|
title: 'Code',
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
label: 'GitHub',
|
label: 'GitHub',
|
||||||
href: 'https://github.com/go-gitea/gitea',
|
href: 'https://github.com/go-gitea/gitea',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Gitea',
|
label: 'Gitea',
|
||||||
href: 'https://gitea.com/gitea',
|
href: 'https://gitea.com/gitea',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'Tea CLI',
|
label: 'Tea CLI',
|
||||||
href: 'https://gitea.com/gitea/tea',
|
href: 'https://gitea.com/gitea/tea',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
prism: {
|
prism: {
|
||||||
theme: lightCodeTheme,
|
theme: lightCodeTheme,
|
||||||
darkTheme: darkCodeTheme,
|
darkTheme: darkCodeTheme,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
|
|||||||
Reference in New Issue
Block a user