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 ;
}
2023-07-07 09:19:52 +00:00
const renderApiSSR = process . env . API_SSR !== 'false' ;
2023-07-05 03:54:54 +00:00
const apiConfig = [
'redocusaurus' ,
{
// Plugin Options for loading OpenAPI files
2023-07-07 09:19:52 +00:00
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' ,
},
{
route : '/api/1.19/' ,
spec : 'static/swagger-19.json' ,
},
] : [],
// Theme Options for modifying how redoc renders them
theme : {
// Change with your site colors
primaryColor : '#1890ff' ,
},
},
]
2023-07-07 09:19:52 +00:00
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' ,
i18n : {
2023-06-08 03:34:23 +00:00
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 : {
2023-06-08 03:34:23 +00:00
'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
2023-05-30 09:42:46 +00:00
editUrl : ({ versionDocsDirPath , docPath , locale , version , permalink }) => {
2023-06-08 03:34:23 +00:00
let fileName = `doc/ ${ docPath . replace ( '.md' , '' ) } . ${ locale } .md` ;
2023-05-30 09:42:46 +00:00
// intro.md has different name from upstream, need to handle this here
if ( docPath . includes ( 'intro.md' )) {
2023-06-08 03:34:23 +00:00
fileName = `page/index. ${ locale } .md` ;
2023-05-30 09:42:46 +00:00
}
2023-06-08 03:34:23 +00:00
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-06-29 18:33:03 +00:00
label : '1.20.0-rc2' ,
2023-06-14 07:05:13 +00:00
banner : 'none' ,
},
'1.19' : {
2023-07-05 17:35:59 +00:00
label : '1.19.4' ,
2023-03-04 12:34:51 +08:00
}
2023-02-02 23:30:20 -05:00
},
2023-06-14 07:05:13 +00:00
lastVersion : '1.19' ,
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' ,
2023-07-12 03:55:43 +00:00
href : 'https://about.gitea.com/' ,
2023-07-12 12:58:44 +00:00
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
{
to : '/api/1.19/' ,
label : 'API' ,
position : 'left' ,
activeBaseRegex : 'api/(1.19|1.20|next)/' ,
},
2023-07-12 03:55:43 +00:00
{
position : 'left' ,
label : 'Blog' ,
href : 'https://blog.gitea.com' ,
className : 'internal-href' ,
2023-07-12 12:58:44 +00:00
target : '_self' ,
2023-07-12 03:55:43 +00:00
},
2023-07-05 03:54:54 +00:00
{
2023-07-07 09:19:52 +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-07 09:19:52 +00:00
{ to : '/api/1.20/' , label : '1.20.0-rc2' },
2023-07-05 17:35:59 +00: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 ,
},
{
to : 'help/seek-help' ,
position : 'right' ,
label : 'Support' ,
activeBaseRegex : 'help/seek-help' ,
2023-07-12 03:55:43 +00:00
},
{
href : 'https://gitea.com/user/login' ,
label : 'Sign In' ,
position : 'right' ,
className : 'internal-href signin-button' ,
2023-07-12 12:58:44 +00:00
target : '_self' ,
2023-07-12 03:55:43 +00:00
},
2023-02-02 23:30:20 -05:00
],
},
footer : {
style : 'dark' ,
links : [
{
title : 'Docs' ,
items : [
{
label : 'Tutorial' ,
to : '/' ,
},
],
},
{
title : 'Community' ,
items : [
{
label : 'Stack Overflow' ,
href : 'https://stackoverflow.com/questions/tagged/gitea' ,
},
{
label : 'Discord' ,
href : 'https://discord.gg/gitea' ,
},
{
label : 'Twitter' ,
href : 'https://twitter.com/giteaio' ,
},
],
},
{
title : 'More' ,
items : [
{
label : 'Code' ,
href : 'https://github.com/go-gitea/gitea' ,
},
],
},
],
},
prism : {
theme : lightCodeTheme ,
darkTheme : darkCodeTheme ,
},
}),
};
module . exports = config ;