mirror of
https://gitea.com/gitea/docs.git
synced 2026-06-29 07:34:22 +00:00
Introduce runner documentations (#133)
This PR introduces documentation for Runner. <img width="959" alt="图片.png" src="attachments/5ad6a8af-d799-4718-9d33-56bf91a8852e"> Co-authored-by: kerwin612 <kerwin612@qq.com> Reviewed-on: https://gitea.com/gitea/docs/pulls/133 Reviewed-by: Bo-Yi Wu (吳柏毅) <appleboy.tw@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
import React from 'react';
|
||||
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
||||
import {useLocation} from '@docusaurus/router';
|
||||
|
||||
export default function APIDropDown(props) {
|
||||
const {pathname} = useLocation();
|
||||
let newLabel = props.label;
|
||||
// isAPI indicates if the current page is a api page
|
||||
let isAPI = false;
|
||||
for (const item of props.items) {
|
||||
// paths like /zh-cn/api/{version}/ are also api pages
|
||||
if (pathname === item.to || pathname === `/zh-cn${item.to}`) {
|
||||
if (!props.mobile) newLabel = item.label;
|
||||
isAPI = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
const newProps = {...props, label: newLabel};
|
||||
// Hide api dropdown on non api pages
|
||||
return (
|
||||
<DropdownNavbarItem {...newProps} className={`api-dropdown${isAPI? '': ' gt-hidden'}`}></DropdownNavbarItem>
|
||||
);
|
||||
}
|
||||
18
src/components/DropDown.js
Normal file
18
src/components/DropDown.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
|
||||
import {useLocation} from '@docusaurus/router';
|
||||
|
||||
export default function DropDown(props) {
|
||||
const {pathname} = useLocation();
|
||||
const {routerRgx, classNames} = props;
|
||||
const r = new RegExp(routerRgx);
|
||||
let isMatched = r.test(pathname);
|
||||
let newLabel = props.label;
|
||||
if (isMatched) {
|
||||
newLabel = props.items.filter(item => item.to === pathname)[0]?.label ?? newLabel;
|
||||
}
|
||||
const newProps = {...props, label: newLabel};
|
||||
return (
|
||||
<DropdownNavbarItem {...newProps} className={`custom-dropdown ${classNames}${isMatched ? ' gt-visible': ' gt-hidden'}`}></DropdownNavbarItem>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user