2023-11-27 04:43:08 +00:00
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
import { themes as prismThemes } from 'prism-react-renderer' ;
const lightCodeTheme = prismThemes . github ;
const darkCodeTheme = prismThemes . dracula ;
// 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' ;
const apiConfig = [
'redocusaurus' ,
{
// Plugin Options for loading OpenAPI files
specs : renderApiSSR ? [
{
route : '/api/next/' ,
2025-01-16 07:01:43 +00:00
spec : 'static/swagger-latest.json' ,
},
{
route : '/api/' ,
spec : 'static/swagger-23.json' ,
},
{
route : '/api/1.23/' ,
spec : 'static/swagger-23.json' ,
2023-11-27 04:43:08 +00:00
},
2024-05-27 13:52:22 +00:00
{
route : '/api/1.22/' ,
spec : 'static/swagger-22.json' ,
},
2023-11-27 04:43:08 +00:00
{
route : '/api/1.21/' ,
spec : 'static/swagger-21.json' ,
},
{
route : '/api/1.20/' ,
spec : 'static/swagger-20.json' ,
},
{
route : '/api/1.19/' ,
spec : 'static/swagger-19.json' ,
2024-05-26 13:01:44 +08:00
}
2023-11-27 04:43:08 +00:00
] : [],
// Theme Options for modifying how redoc renders them
theme : {
// Change with your site colors
primaryColor : '#1890ff' ,
},
},
]
const pageConfig = renderApiSSR ? {
exclude : [
'api/**' ,
],
} : {}
2024-08-31 23:14:38 -07:00
const globalVariables = {
current : {
2025-01-10 05:28:14 +00:00
'goVersion' : '1.23' ,
'minGoVersion' : '1.23' ,
2024-08-31 23:14:38 -07:00
'minNodeVersion' : '18' ,
'version' : 'main-nightly' ,
2024-08-31 23:36:04 -07:00
'sourceVersion' : 'main' ,
'sourceBranch' : 'main' ,
2024-08-31 23:14:38 -07:00
'dockerVersion' : 'nightly' ,
2024-12-18 07:44:42 +00:00
'displayVersion' : '1.24-dev'
},
'1.23' : {
'goVersion' : '1.23' ,
'minGoVersion' : '1.22' ,
'minNodeVersion' : '18' ,
2025-03-24 14:53:49 -07:00
'version' : '1.23.6' ,
2025-01-10 05:28:14 +00:00
'sourceVersion' : 'v1.23.0' ,
2024-12-18 07:44:42 +00:00
'sourceBranch' : 'release/v1.23' ,
2025-03-24 14:53:49 -07:00
'dockerVersion' : '1.23.6' ,
'displayVersion' : '1.23.6'
2024-08-31 23:14:38 -07:00
},
'1.22' : {
'goVersion' : '1.22' ,
'minGoVersion' : '1.22' ,
'minNodeVersion' : '18' ,
2024-12-13 00:09:11 -08:00
'version' : '1.22.6' ,
2024-12-18 07:44:42 +00:00
'sourceVersion' : 'v1.22.6' ,
2024-08-31 23:36:04 -07:00
'sourceBranch' : 'release/v1.22' ,
2024-12-13 00:09:11 -08:00
'dockerVersion' : '1.22.6' ,
'displayVersion' : '1.22.6'
2024-08-31 23:14:38 -07:00
},
'1.21' : {
'goVersion' : '1.21' ,
'minGoVersion' : '1.21' ,
'minNodeVersion' : '18' ,
'version' : '1.21.11' ,
2024-08-31 23:36:04 -07:00
'sourceVersion' : 'v1.21.11' ,
'sourceBranch' : 'release/v1.21' ,
2024-08-31 23:14:38 -07:00
'dockerVersion' : '1.21.11' ,
'displayVersion' : '1.21.11'
},
'1.20' : {
'goVersion' : '1.20' ,
'minGoVersion' : '1.20' ,
'minNodeVersion' : '16' ,
'version' : '1.20.6' ,
2024-08-31 23:36:04 -07:00
'sourceVersion' : 'v1.20.6' ,
'sourceBranch' : 'release/v1.20' ,
2024-08-31 23:14:38 -07:00
'dockerVersion' : '1.20.6' ,
'displayVersion' : '1.20.6'
},
'1.19' : {
'goVersion' : '1.20' ,
'minGoVersion' : '1.19' ,
'minNodeVersion' : '14' ,
'version' : '1.19.4' ,
2024-08-31 23:36:04 -07:00
'sourceVersion' : 'v1.19.4' ,
'sourceBranch' : 'release/v1.19' ,
2024-08-31 23:14:38 -07:00
'dockerVersion' : '1.19.4' ,
'displayVersion' : '1.19.4'
}
}
const versions = {
current : {
label : globalVariables [ 'current' ]. displayVersion , // path is kept as next for dev (so users can always find "nightly" docs)
banner : 'unreleased' ,
},
2024-12-18 07:44:42 +00:00
'1.23' : {
label : globalVariables [ '1.23' ]. displayVersion ,
},
2024-08-31 23:14:38 -07:00
'1.22' : {
label : globalVariables [ '1.22' ]. displayVersion ,
},
'1.21' : {
label : globalVariables [ '1.21' ]. displayVersion ,
},
'1.20' : {
label : globalVariables [ '1.20' ]. displayVersion ,
},
'1.19' : {
label : globalVariables [ '1.19' ]. displayVersion ,
}
}
2023-11-27 04:43:08 +00:00
/** @type {import('@docusaurus/types').Config} */
const config = {
title : 'Gitea Documentation' ,
tagline : 'Git with a cup of tea' ,
url : 'https://docs.gitea.com' ,
baseUrl : '/' ,
2024-06-07 00:21:50 +08:00
onBrokenLinks : 'warn' ,
onBrokenMarkdownLinks : 'warn' ,
2023-11-27 04:43:08 +00:00
favicon : 'img/favicon.png' ,
2025-01-10 19:15:45 +00:00
future : {
experimental_faster : true
},
2023-11-27 04:43:08 +00:00
plugins : [
[
'docusaurus-plugin-plausible' ,
{
domain : 'docs.gitea.com' ,
},
2024-12-26 23:44:25 +00:00
],
// for runner documentations
[
'@docusaurus/plugin-content-docs' ,
{
id : 'runner' ,
path : 'runner' ,
routeBasePath : 'runner' ,
//sidebarPath: './runner/sidebars.js',
versions : {
current : {
label : 'main' ,
banner : 'unreleased' ,
},
"0.2.11" : {
path : '0.2.11' ,
label : '0.2.11' ,
}
},
lastVersion : '0.2.11' ,
editUrl : ({ versionDocsDirPath , docPath , locale , version , permalink }) => {
return `https://gitea.com/gitea/docs/src/branch/main/ ${ version === 'current' ? 'runner' : `runner_versioned_docs/version- ${ version } ` } / ${ docPath } ` ;
},
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-11-27 04:43:08 +00:00
],
i18n : {
defaultLocale : 'en-us' ,
2024-06-06 20:44:06 +08:00
locales : [ 'en-us' , 'zh-cn' /*,'fr-fr', 'zh-tw'*/ ], // temporarily disable other locales
2023-11-27 04:43:08 +00:00
localeConfigs : {
'en-us' : {
label : 'English' ,
},
'zh-cn' : {
label : '中文' ,
},
},
},
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 }) => {
2024-02-19 16:13:00 +00:00
// Special case for awesome page
if ( docPath . includes ( 'awesome.md' )) {
return `https://gitea.com/gitea/awesome-gitea/src/branch/main/README.md`
}
2024-07-17 04:22:05 +00:00
if ( locale === 'en-us' ) {
return `https://gitea.com/gitea/docs/src/branch/main/ ${ version === 'current' ? 'docs' : `versioned_docs/version- ${ version } ` } / ${ docPath } ` ;
}
return `https://gitea.com/gitea/docs/src/branch/main/i18n/ ${ locale } /docusaurus-plugin-content-docs/ ${ version === 'current' ? 'current' : `version- ${ version } ` } / ${ docPath } ` ;
2023-11-27 04:43:08 +00:00
},
2024-08-31 23:14:38 -07:00
versions : versions ,
2025-01-10 18:58:33 +00:00
lastVersion : '1.23' ,
2023-11-27 04:43:08 +00: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 );
}
},
},
blog : false ,
theme : {
customCss : require . resolve ( './src/css/custom.css' ),
},
pages : pageConfig ,
2024-03-19 13:39:51 +00:00
gtag : {
trackingID : 'G-KHM0KYT506'
},
2023-11-27 04:43:08 +00:00
}),
],
apiConfig ,
],
2024-08-31 23:14:38 -07:00
markdown : {
preprocessor : ({ filePath , fileContent }) => {
var key = '' ;
var found = false ;
for ( key in globalVariables ) {
let folderName = ( key == 'current' ? 'current' : `version- ${ key } ` );
if ( filePath . includes ( `/ ${ folderName } /` )) {
found = true ;
break ;
}
}
if ( key == '' || ! found ) {
key = 'current' ;
}
let content = fileContent ;
for ( const variable in globalVariables [ key ]) {
content = content . replaceAll ( '@' + variable + '@' , globalVariables [ key ][ variable ]);
}
return content
},
},
2023-11-27 04:43:08 +00:00
themes : [
[
"@easyops-cn/docusaurus-search-local" ,
{
hashed : false ,
language : [ "en" , "zh" ],
highlightSearchTermsOnTargetPage : true ,
explicitSearchResultPath : true ,
indexBlog : false ,
docsRouteBasePath : "/"
}
]
],
themeConfig :
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
2024-06-14 08:53:10 +00:00
metadata : [
{ name : 'keywords' , content : 'gitea, git, devops, actions, packages, documentation, self-hosted, open-source, version control, gitlab, github' }
],
2023-11-27 04:43:08 +00:00
colorMode : {
defaultMode : 'light' ,
disableSwitch : false ,
respectPrefersColorScheme : true ,
},
2023-12-07 17:37:02 +00:00
announcementBar : {
id : 'announcementBar-4' , // Increment on change
2023-12-20 06:47:49 +00:00
content : `<a href="https://about.gitea.com/products/cloud">Try Gitea Cloud ☁️ for 30 days <span aria-hidden="true">→</span> Accelerate your Development & Deploys!</a>` ,
2023-12-07 17:37:02 +00:00
},
2023-11-27 04:43:08 +00:00
navbar : {
title : 'Gitea' ,
logo : {
alt : 'Gitea Logo' ,
src : 'img/gitea.svg' ,
href : 'https://about.gitea.com/' ,
target : '_self' ,
},
items : [
{
type : 'doc' ,
2024-06-06 20:44:06 +08:00
docId : 'index' ,
2023-11-27 04:43:08 +00:00
position : 'left' ,
label : 'Docs' ,
},
{
2025-01-10 05:28:14 +00:00
to : '/api/1.23/' ,
2023-11-27 04:43:08 +00:00
label : 'API' ,
position : 'left' ,
2024-12-18 07:44:42 +00:00
activeBaseRegex : 'api/(1.19|1.20|1.21|1.22|1.23|next)/' ,
2023-11-27 04:43:08 +00:00
},
{
2024-12-26 23:44:25 +00:00
to : '/runner/0.2.11/' ,
label : 'Runner' ,
2023-11-27 04:43:08 +00:00
position : 'left' ,
2024-12-26 23:44:25 +00:00
activeBaseRegex : 'runner/(0.2.11|next)/' ,
2023-11-27 04:43:08 +00:00
},
2024-03-07 09:02:49 +00:00
{
position : 'left' ,
label : 'Enterprise' ,
href : 'https://docs.gitea.com/enterprise' ,
className : 'internal-href' ,
target : '_self' ,
},
2023-11-27 04:43:08 +00:00
{
type : 'search' ,
position : 'right' ,
},
2024-06-07 18:03:08 +08:00
{
2023-11-27 04:43:08 +00:00
type : 'localeDropdown' ,
position : 'right' ,
2024-06-07 18:03:08 +08:00
},
2023-11-27 04:43:08 +00:00
{
type : 'docsVersionDropdown' ,
position : 'right' ,
dropdownActiveClassDisabled : true ,
},
2024-12-26 23:44:25 +00:00
{
type : 'custom-Dropdown' ,
label : 'API Version' ,
position : 'right' ,
items : [
{ to : '/api/next/' , label : '1.24-dev' },
2025-03-24 14:53:49 -07:00
{ to : '/api/1.23/' , label : '1.23.6' },
2024-12-26 23:44:25 +00:00
{ to : '/api/1.22/' , label : '1.22.6' },
{ to : '/api/1.21/' , label : '1.21.11' },
{ to : '/api/1.20/' , label : '1.20.6' },
{ to : '/api/1.19/' , label : '1.19.4' },
],
routerRgx : '\/api\/' ,
classNames : 'api-dropdown' ,
},
{
type : 'custom-Dropdown' ,
label : 'Runner Version' ,
position : 'right' ,
items : [
{ to : '/runner/next/' , label : 'development' },
{ to : '/runner/0.2.11/' , label : '0.2.11' },
],
routerRgx : '\/runner\/' ,
classNames : 'runner-dropdown' ,
},
2023-11-27 04:43:08 +00:00
{
to : 'help/support' ,
position : 'right' ,
label : 'Support' ,
activeBaseRegex : 'help/support' ,
},
{
href : 'https://gitea.com/user/login' ,
label : 'Sign In' ,
position : 'right' ,
className : 'internal-href signin-button' ,
target : '_self' ,
},
],
},
footer : {
style : 'dark' ,
links : [
{
title : 'Community' ,
items : [
{
label : 'Awesome Gitea' ,
2024-06-07 00:21:50 +08:00
href : 'https://gitea.com/gitea/awesome-gitea' ,
2023-11-27 04:43:08 +00:00
},
{
label : 'Stack Overflow' ,
href : 'https://stackoverflow.com/questions/tagged/gitea' ,
},
{
label : 'Discord' ,
href : 'https://discord.gg/gitea' ,
},
{
label : 'Matrix' ,
href : 'https://matrix.to/#/#gitea-space:matrix.org' ,
},
{
label : 'Forum' ,
href : 'https://forum.gitea.com/' ,
},
{
label : 'Twitter' ,
href : 'https://twitter.com/giteaio' ,
},
{
label : 'Mastodon' ,
href : 'https://social.gitea.io/@gitea' ,
},
],
},
{
title : 'Code' ,
items : [
{
label : 'GitHub' ,
href : 'https://github.com/go-gitea/gitea' ,
},
{
label : 'Gitea' ,
href : 'https://gitea.com/gitea' ,
},
{
label : 'Tea CLI' ,
href : 'https://gitea.com/gitea/tea' ,
},
],
},
],
},
prism : {
theme : lightCodeTheme ,
darkTheme : darkCodeTheme ,
2024-06-07 18:03:08 +08:00
additionalLanguages : [ 'ini' , 'diff' , 'json' , 'http' , 'docker' , 'php' ],
2023-11-27 04:43:08 +00:00
},
}),
};
module . exports = config ;