Files
docs/docusaurus.config.js
T

548 lines
14 KiB
JavaScript
Raw Normal View History

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