mirror of
https://gitea.com/gitea/docs.git
synced 2026-07-01 00:24:38 +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>
|
||||
);
|
||||
}
|
||||
@@ -131,6 +131,14 @@
|
||||
body:has(.redocusaurus) .navbar__item.dropdown:not(:has(.api-dropdown)) {
|
||||
display: none;
|
||||
}
|
||||
/* hide other dropdowns except for runner dropdown on runner pages */
|
||||
body:has(.runner-dropdown.gt-visible) .navbar__item.dropdown:not(:has(.runner-dropdown)) {
|
||||
display: none;
|
||||
}
|
||||
/* hide dropdown menus that have sub-elements containing 'gt-hidden' */
|
||||
body .navbar__item.dropdown:has(.custom-dropdown.gt-hidden) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 996px) {
|
||||
@@ -139,6 +147,14 @@
|
||||
body:has(.redocusaurus) .menu__list-item.menu__list-item--collapsed:not(:has(.api-dropdown)) {
|
||||
display: none;
|
||||
}
|
||||
/* Hide collapsible menus except for Runner menu on Runner pages */
|
||||
body:has(.runner-dropdown.gt-visible) .menu__list-item.menu__list-item--collapsed:not(:has(.runner-dropdown)) {
|
||||
display: none;
|
||||
}
|
||||
/* Hide dropdown menus that have sub-elements containing 'gt-hidden' */
|
||||
body .menu__list-item.menu__list-item--collapsed:has(.custom-dropdown.gt-hidden) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* selectors like :first-of-type are for browsers those do not support :has */
|
||||
|
||||
@@ -7,7 +7,7 @@ import DocNavbarItem from '@theme/NavbarItem/DocNavbarItem';
|
||||
import DocSidebarNavbarItem from '@theme/NavbarItem/DocSidebarNavbarItem';
|
||||
import DocsVersionNavbarItem from '@theme/NavbarItem/DocsVersionNavbarItem';
|
||||
import DocsVersionDropdownNavbarItem from '@theme/NavbarItem/DocsVersionDropdownNavbarItem';
|
||||
import APIDropDown from '@site/src/components/APIDropDown';
|
||||
import DropDown from '@site/src/components/DropDown';
|
||||
|
||||
const ComponentTypes = {
|
||||
default: DefaultNavbarItem,
|
||||
@@ -19,6 +19,6 @@ const ComponentTypes = {
|
||||
docSidebar: DocSidebarNavbarItem,
|
||||
docsVersion: DocsVersionNavbarItem,
|
||||
docsVersionDropdown: DocsVersionDropdownNavbarItem,
|
||||
'custom-apiDropdown': APIDropDown,
|
||||
'custom-Dropdown': DropDown,
|
||||
};
|
||||
export default ComponentTypes;
|
||||
|
||||
Reference in New Issue
Block a user