mirror of
https://gitea.com/gitea/docs.git
synced 2026-09-17 19:55:34 +00:00
Add api page (#32)
# Changes - Added [redocusaurus](https://github.com/rohit-gohri/redocusaurus) package to display swagger api with reference to [woodpecker](https://github.com/woodpecker-ci/woodpecker/tree/master/docs) - Change `sed` for swagger.json for proper version and baseurl. - Add a dropdown for different api versions. (screenshot below) - On API pages, only API version dropdown will show(hide locale dropdown, version dropdown for doc, and doc search) - Allow build CSR API pages for development so it saves building time. # Screenshots     Search:  Reviewed-on: https://gitea.com/gitea/gitea-docusaurus/pulls/32 Co-authored-by: HesterG <[email protected]> Co-committed-by: HesterG <[email protected]>
This commit is contained in:
+55
-1
@@ -13,6 +13,40 @@ function sortItemsByCategory(items) {
|
||||
return sortedItems;
|
||||
}
|
||||
|
||||
const includeAPI = process.env.INCLUDE_API !== 'false';
|
||||
|
||||
const apiConfig = [
|
||||
'redocusaurus',
|
||||
{
|
||||
// Plugin Options for loading OpenAPI files
|
||||
specs: includeAPI ? [
|
||||
{
|
||||
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',
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
const pageConfig = includeAPI ? {
|
||||
exclude: [
|
||||
'api/**',
|
||||
],
|
||||
}: {}
|
||||
|
||||
/** @type {import('@docusaurus/types').Config} */
|
||||
const config = {
|
||||
title: 'Gitea Documentation',
|
||||
@@ -82,8 +116,10 @@ const config = {
|
||||
theme: {
|
||||
customCss: require.resolve('./src/css/custom.css'),
|
||||
},
|
||||
pages: pageConfig,
|
||||
}),
|
||||
],
|
||||
apiConfig,
|
||||
],
|
||||
themes: [
|
||||
[
|
||||
@@ -119,10 +155,28 @@ const config = {
|
||||
},
|
||||
items: [
|
||||
{
|
||||
to: '/',
|
||||
type: 'doc',
|
||||
docId: 'intro',
|
||||
position: 'left',
|
||||
label: 'Docs',
|
||||
},
|
||||
{
|
||||
to: '/api/1.19/',
|
||||
label: 'API',
|
||||
position: 'left',
|
||||
activeBaseRegex: 'api/(1.19|1.20|next)/',
|
||||
},
|
||||
{
|
||||
type: 'dropdown',
|
||||
label: 'API Version',
|
||||
position: 'right',
|
||||
items: [
|
||||
{to: '/api/next/', label: '1.21-dev' },
|
||||
{to: '/api/1.20/', label: '1.20.0-rc0' },
|
||||
{to: '/api/1.19/', label: '1.19.3' },
|
||||
],
|
||||
className: 'api-dropdown',
|
||||
},
|
||||
{
|
||||
href: 'https://github.com/go-gitea/gitea',
|
||||
label: 'Code',
|
||||
|
||||
Reference in New Issue
Block a user