feat: add license files for JavaScript assets and implement DocItem component

- Added LICENSE.txt file for JavaScript assets in the build directory, including licenses for NProgress and React libraries.
- Introduced a new runtime JavaScript file for handling module loading.
- Created a new DocItem component to manage document rendering and metadata handling in the Docusaurus theme.
- Implemented tests for the docs proxy server to ensure proper routing to the configured docsPort.
This commit is contained in:
catlog22
2026-02-06 10:25:24 +08:00
parent f9188eb0b6
commit a9b9ec48f1
91 changed files with 780 additions and 217 deletions

View File

@@ -0,0 +1,46 @@
import React, {type ReactNode} from 'react';
import {HtmlClassNameProvider} from '@docusaurus/theme-common';
import {useLocation} from '@docusaurus/router';
import {DocProvider} from '@docusaurus/plugin-content-docs/client';
import DocItemMetadata from '@theme/DocItem/Metadata';
import DocItemLayout from '@theme/DocItem/Layout';
import NotFoundContent from '@theme/NotFound/Content';
import type {Props} from '@theme/DocItem';
export default function DocItem(props: Props): ReactNode {
const location = useLocation();
// Docusaurus expects `content` to be a MDX component function with a
// `metadata` property attached. Under certain dev/proxy edge cases, this can
// be missing and the default theme crashes with:
// "Cannot read properties of undefined (reading 'id')".
const content = (props as unknown as {content?: unknown}).content as
| {metadata?: {id?: string}}
| undefined;
const docId = content?.metadata?.id;
if (!docId) {
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line no-console
console.error('[DocItem] Missing doc metadata', {
pathname: location.pathname,
});
}
return <NotFoundContent />;
}
const docHtmlClassName = `docs-doc-id-${docId}`;
const MDXComponent = props.content;
return (
<DocProvider content={props.content}>
<HtmlClassNameProvider className={docHtmlClassName}>
<DocItemMetadata />
<DocItemLayout>
<MDXComponent />
</DocItemLayout>
</HtmlClassNameProvider>
</DocProvider>
);
}