1- /// <reference path="../../index.d.ts" />
2-
3- import { useLang , usePageData } from '@rspress/core/runtime' ;
1+ import { useLang } from '@rspress/core/runtime' ;
42// @ts -expect-error @theme is overridden by alias in @rspress/core
53import { getCustomMDXComponent } from '@theme' ;
4+ import GithubSlugger from 'github-slugger' ;
5+ import type { Content , Element , Root } from 'hast' ;
66import ReactMarkdown from 'react-markdown' ;
77import remarkGfm from 'remark-gfm' ;
88import './API.css' ;
9- import GithubSlugger from 'github-slugger' ;
10- import type { Content , Element , Root } from 'hast' ;
119// biome-ignore lint/style/useImportType: <exact>
1210import React from 'react' ;
1311import type { Plugin } from 'unified' ;
1412import { visit } from 'unist-util-visit' ;
1513
14+ declare global {
15+ var RSPRESS_PLUGIN_API_DOCGEN_MAP : Record < string , string > ;
16+ }
17+
1618function headingRank ( node : Root | Content ) : number | null {
1719 const name =
1820 ( node && node . type === 'element' && node . tagName . toLowerCase ( ) ) || '' ;
@@ -98,12 +100,11 @@ const collectHeaderText = (node: Element): string => {
98100 return text ;
99101} ;
100102
101- export default ( props : { moduleName : string } ) => {
103+ const API = ( props : { moduleName : string } ) => {
102104 const lang = useLang ( ) ;
103- const { page } = usePageData ( ) ;
104105 const { moduleName } = props ;
105106 // some api doc have two languages.
106- const apiDocMap = page . apiDocMap ;
107+ const apiDocMap = RSPRESS_PLUGIN_API_DOCGEN_MAP ;
107108 // avoid error when no page data
108109 const apiDoc =
109110 apiDocMap ?. [ moduleName ] || apiDocMap ?. [ `${ moduleName } -${ lang } ` ] || '' ;
@@ -122,3 +123,5 @@ export default (props: { moduleName: string }) => {
122123 </ div >
123124 ) ;
124125} ;
126+
127+ export default API ;
0 commit comments