refactor: drop the remaining docusaurus names from identifiers and comments (#589)

Follow-up to #588.

- rename `DocusaurusSidebarItem` -> `SidebarSourceItem`, `fromDocusaurus` -> `fromSidebarSource`, `docusaurusSidebars` -> `sidebarSources`
- reword comments and READMEs that described behaviour by comparison with docusaurus; fix the stale note in `sites/docs/src/config/api.ts`
- drop `.docusaurus/` from `.gitignore`

No functional change. `pnpm check` has 0 errors and `pnpm build` still builds 6690 pages.

<!-- cloudflare-preview --> Preview: https://pr-589.docs-gitea-com.pages.dev

Reviewed-on: https://gitea.com/gitea/docs/pulls/589
Reviewed-by: silverwind <[email protected]>
This commit is contained in:
Lunny Xiao committed 2026-10-15 17:39:24 +00:00
1 parent 2275bef3bd
commit b555a247e0
15 files changed
+46 -48

No files matched your search

+3 -3
View File
@@ -49,17 +49,17 @@ of every file, the second normalizes and renders it:
- substitutes the version variables (`@version@`, `@dockerVersion@`, ...)
- lifts the leading `# heading` into the starlight `title`
- maps `sidebar_position` to `sidebar.order` and honours the docusaurus `slug`,
- maps `sidebar_position` to `sidebar.order` and honours the `slug`,
including the translations that moved a page
- rewrites the relative `*.md` links to urls, resolving them against the file
and against the version root, and reports the ones that do not resolve
- turns the docusaurus admonitions into starlight asides (`:::warning` to
- turns the admonitions into starlight asides (`:::warning` to
`:::caution`, `:::info` to `:::note`, `:::note Title` to `:::note[Title]`)
- recreates the index pages of `_category_.json` (`/category/installation/`,
`/usage/actions/`)
Sidebars are built per (product, version, language) from `_category_.json` and
from the docusaurus sidebar files (`sidebars.js`, `versioned_sidebars/`,
from the sidebar files (`sidebars.js`, `versioned_sidebars/`,
`runner-sidebars.js`, `runner-docs_versioned_sidebars/`), and selected in
`src/routeData.ts`, since starlight only supports a single static sidebar.
@@ -4,7 +4,7 @@ import { t } from '../config/strings';
import { searchFilters } from '../lib/search';
/**
* Translated pages carry the notice the docusaurus site showed: a translation
* Translated pages carry the notice: a translation
* can lag behind the english original, so point at it and at the translation
* guide. Fallback pages already get starlight's own notice.
*
+1 -1
View File
@@ -81,7 +81,7 @@ function hyphenateOperationIds(document: SwaggerDocument): void {
* `update_api_docs.sh` rewrites `basePath` of the swagger documents to the full
* `https://gitea.com/api/v1` url, which redoc accepted but is not valid swagger
* 2.0: the host belongs into `host` and the scheme into `schemes`. Normalize a
* copy instead of touching the sources, which the docusaurus site still reads.
* copy instead of touching the sources, which other tooling still reads.
*
* The openapi 3.0 documents keep the url in `servers`, where a full url is
* valid, so only the operation ids and the tags are touched for those.
+8 -8
View File
@@ -4,7 +4,7 @@ import path from 'node:path';
import {
buildSidebars,
products,
type DocusaurusSidebarItem,
type SidebarSourceItem,
type SidebarEntry,
type SidebarPage,
} from '@gitea-docs/content-loader';
@@ -12,21 +12,21 @@ import { getCollection } from 'astro:content';
import { repoRoot } from '../config/paths';
/**
* Sidebar files of the docusaurus site: the top level order of the docs and the
* Sidebar files: the top level order of the docs and the
* handwritten sidebars of the runner, one per version. Read as is, so cutting a
* version keeps needing no change here.
*/
function docusaurusSidebars(): Map<string, DocusaurusSidebarItem[]> {
const sidebars = new Map<string, DocusaurusSidebarItem[]>();
function sidebarSources(): Map<string, SidebarSourceItem[]> {
const sidebars = new Map<string, SidebarSourceItem[]>();
const require = createRequire(import.meta.url);
const read = (file: string): Record<string, DocusaurusSidebarItem[]> | undefined => {
const read = (file: string): Record<string, SidebarSourceItem[]> | undefined => {
const full = path.join(repoRoot, file);
if (!existsSync(full)) return undefined;
try {
return file.endsWith('.json')
? (JSON.parse(readFileSync(full, 'utf-8')) as Record<string, DocusaurusSidebarItem[]>)
: (require(full) as Record<string, DocusaurusSidebarItem[]>);
? (JSON.parse(readFileSync(full, 'utf-8')) as Record<string, SidebarSourceItem[]>)
: (require(full) as Record<string, SidebarSourceItem[]>);
} catch (error) {
// an unreadable sidebar would silently fall back to the directory tree,
// which reorders the whole navigation without any other sign
@@ -73,4 +73,4 @@ const pages: SidebarPage[] = entries.flatMap((entry) => {
});
/** Sidebars of every (product, version, language), keyed by their route prefix. */
export const sidebars: Map<string, SidebarEntry[]> = buildSidebars(pages, docusaurusSidebars());
export const sidebars: Map<string, SidebarEntry[]> = buildSidebars(pages, sidebarSources());