Skip to content

Commit ca23bbe

Browse files
committed
chore(ui): add toc
1 parent 19ee2df commit ca23bbe

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

npm-shrinkwrap.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"@clack/prompts": "^0.11.0",
4444
"@heroicons/react": "^2.2.0",
4545
"@node-core/rehype-shiki": "1.3.0",
46-
"@node-core/ui-components": "1.5.3",
46+
"@node-core/ui-components": "1.5.6",
4747
"@orama/orama": "^3.1.18",
4848
"@orama/ui": "^1.5.4",
4949
"@rollup/plugin-virtual": "^3.0.2",

src/generators/jsx-ast/utils/buildContent.mjs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ export const processEntry = (entry, remark) => {
258258
/**
259259
* Builds the overall document layout tree
260260
* @param {Array<ApiDocMetadataEntry>} entries - API documentation metadata entries
261-
* @param {Record<string, any>} sideBarProps - Props for the sidebar component
262-
* @param {Record<string, any>} metaBarProps - Props for the meta bar component
261+
* @param {ReturnType<import('./buildJSXProps.mjs').buildSideBarProps>} sideBarProps - Props for the sidebar component
262+
* @param {ReturnType<buildMetaBarProps>} metaBarProps - Props for the meta bar component
263263
* @param {import('unified').Processor} remark - The remark processor
264264
*/
265265
export const createDocumentLayout = (
@@ -274,10 +274,17 @@ export const createDocumentLayout = (
274274
children: [
275275
createJSXElement(JSX_IMPORTS.SideBar.name, sideBarProps),
276276
createElement('div', [
277-
createElement(
278-
'main',
279-
entries.map(entry => processEntry(entry, remark))
280-
),
277+
createElement('div', [
278+
createJSXElement(JSX_IMPORTS.TableOfContents.name, {
279+
headings: metaBarProps.headings,
280+
summaryTitle: 'On this page',
281+
}),
282+
createElement('br'),
283+
createElement(
284+
'main',
285+
entries.map(entry => processEntry(entry, remark))
286+
),
287+
]),
281288
createJSXElement(JSX_IMPORTS.MetaBar.name, metaBarProps),
282289
]),
283290
],

src/generators/web/constants.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export const ROOT = dirname(fileURLToPath(import.meta.url));
1111
*/
1212

1313
/**
14-
* @type {Record<string, JSXImportConfig>}
1514
* An object containing mappings for various JSX components to their import paths.
1615
*/
1716
export const JSX_IMPORTS = {
@@ -50,6 +49,10 @@ export const JSX_IMPORTS = {
5049
isDefaultExport: false,
5150
source: '@node-core/ui-components/MDX/Tooltip',
5251
},
52+
TableOfContents: {
53+
name: 'TableOfContents',
54+
source: '@node-core/ui-components/Common/TableOfContents',
55+
},
5356
ChangeHistory: {
5457
name: 'ChangeHistory',
5558
source: '@node-core/ui-components/Common/ChangeHistory',

0 commit comments

Comments
 (0)