1- /// <reference path="../../index.d.ts" />
2-
3- import { useLang , usePageData } from '@rspress/core/runtime' ;
4- // @ts -expect-error @theme is overridden by alias in @rspress/core
5- import { getCustomMDXComponent } from '@theme' ;
1+ import { useLang } from '@rspress/core/runtime' ;
2+ import { getCustomMDXComponent } from '@rspress/core/theme' ;
3+ import GithubSlugger from 'github-slugger' ;
4+ import type { Content , Element , Root } from 'hast' ;
65import ReactMarkdown from 'react-markdown' ;
76import remarkGfm from 'remark-gfm' ;
87import './API.css' ;
9- import GithubSlugger from 'github-slugger' ;
10- import type { Content , Element , Root } from 'hast' ;
118// biome-ignore lint/style/useImportType: <exact>
129import React from 'react' ;
1310import type { Plugin } from 'unified' ;
1411import { visit } from 'unist-util-visit' ;
1512
13+ declare global {
14+ var RSPRESS_PLUGIN_API_DOCGEN_MAP : Record < string , string > ;
15+ }
16+
1617function headingRank ( node : Root | Content ) : number | null {
1718 const name =
1819 ( node && node . type === 'element' && node . tagName . toLowerCase ( ) ) || '' ;
@@ -98,12 +99,11 @@ const collectHeaderText = (node: Element): string => {
9899 return text ;
99100} ;
100101
101- export default ( props : { moduleName : string } ) => {
102+ const API = ( props : { moduleName : string } ) => {
102103 const lang = useLang ( ) ;
103- const { page } = usePageData ( ) ;
104104 const { moduleName } = props ;
105105 // some api doc have two languages.
106- const apiDocMap = page . apiDocMap ;
106+ const apiDocMap = RSPRESS_PLUGIN_API_DOCGEN_MAP ;
107107 // avoid error when no page data
108108 const apiDoc =
109109 apiDocMap ?. [ moduleName ] || apiDocMap ?. [ `${ moduleName } -${ lang } ` ] || '' ;
@@ -122,3 +122,5 @@ export default (props: { moduleName: string }) => {
122122 </ div >
123123 ) ;
124124} ;
125+
126+ export default API ;
0 commit comments