mirror of
https://gitea.com/gitea/docs.git
synced 2026-06-30 16:14:23 +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 <hestergong@gmail.com> Co-committed-by: HesterG <hestergong@gmail.com>
This commit is contained in:
12
src/components/ClientOnly.js
Normal file
12
src/components/ClientOnly.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import React from 'react';
|
||||
import ApiDoc from '@theme/ApiDoc';
|
||||
// For csr api pages
|
||||
export default function ClientOnly(props) {
|
||||
return (
|
||||
<ApiDoc
|
||||
specProps={{
|
||||
url: props.swaggerPath,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react'
|
||||
import React from 'react';
|
||||
import Translate from '@docusaurus/Translate';
|
||||
|
||||
export default function Outdated(props) {
|
||||
|
||||
@@ -58,3 +58,57 @@
|
||||
background-color: rgb(7, 19, 24);
|
||||
color: rgb(184, 231, 251);
|
||||
}
|
||||
|
||||
.redocusaurus .menu-content {
|
||||
top: 70px !important;
|
||||
height: calc(100vh - 70px) !important;
|
||||
}
|
||||
/* The following css is for toggling API version dropdown/menu,
|
||||
selectors like :first-of-type are for browsers those do not support :has */
|
||||
/* Do not show doc search on api pages */
|
||||
body:has(.redocusaurus) [class*='searchBox'],
|
||||
.plugin-redoc [class*='searchBox'],
|
||||
.plugin-pages [class*='searchBox'] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 996px) {
|
||||
/* hide api-dropdown on other pages */
|
||||
.navbar__item.dropdown:not(:has(.api-dropdown)),
|
||||
.navbar__item.dropdown:first-of-type {
|
||||
display: none;
|
||||
}
|
||||
/* show api-dropdown dropdown and hide other dropdowns on api pages */
|
||||
body:has(.redocusaurus) .navbar__item.dropdown:not(:has(.api-dropdown)),
|
||||
.plugin-redoc .navbar__item.dropdown:not(:first-of-type),
|
||||
.plugin-pages .navbar__item.dropdown:not(:first-of-type) {
|
||||
display: none;
|
||||
}
|
||||
body:has(.redocusaurus) .navbar__item.dropdown:has(.api-dropdown),
|
||||
.plugin-redoc .navbar__item.dropdown:first-of-type,
|
||||
.plugin-pages .navbar__item.dropdown:first-of-type {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 996px) {
|
||||
/* need to find a way to customize the classname */
|
||||
/* on mobile, dropdown becomes menu list */
|
||||
/* Hide api version menu on other pages */
|
||||
.menu__list-item.menu__list-item--collapsed:has(.api-dropdown),
|
||||
.menu__list-item.menu__list-item--collapsed:nth-of-type(3) {
|
||||
display: none;
|
||||
}
|
||||
/* Hide collapsible menus except for API menu on API pages */
|
||||
body:has(.redocusaurus) .menu__list-item.menu__list-item--collapsed:not(:has(.api-dropdown)),
|
||||
.plugin-redoc .menu__list-item.menu__list-item--collapsed:not(:first-of-type),
|
||||
.plugin-pages .menu__list-item.menu__list-item--collapsed:not(:first-of-type) {
|
||||
display: none;
|
||||
}
|
||||
/* Show collapsible API menu on API pages */
|
||||
body:has(.redocusaurus) .menu__list-item:has(.api-dropdown),
|
||||
.plugin-redoc .menu__list-item:nth-of-type(3),
|
||||
.plugin-pages .menu__list-item:nth-of-type(3) {
|
||||
display: list-item !important;
|
||||
}
|
||||
}
|
||||
|
||||
8
src/pages/api/1.19/index.js
Normal file
8
src/pages/api/1.19/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import React from 'react';
|
||||
import ClientOnly from '@site/src/components/ClientOnly';
|
||||
|
||||
export default function Api19() {
|
||||
return (
|
||||
<ClientOnly swaggerPath="/swagger-19.json"/>
|
||||
);
|
||||
}
|
||||
8
src/pages/api/1.20/index.js
Normal file
8
src/pages/api/1.20/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import React from 'react';
|
||||
import ClientOnly from '@site/src/components/ClientOnly';
|
||||
|
||||
export default function Api20() {
|
||||
return (
|
||||
<ClientOnly swaggerPath="/swagger-20.json"/>
|
||||
);
|
||||
}
|
||||
8
src/pages/api/next/index.js
Normal file
8
src/pages/api/next/index.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import React from 'react';
|
||||
import ClientOnly from '@site/src/components/ClientOnly';
|
||||
|
||||
export default function ApiLatest() {
|
||||
return (
|
||||
<ClientOnly swaggerPath="/swagger-latest.json"/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user