Skip to content

Commit b3f8062

Browse files
committed
rebase
1 parent 39bbf93 commit b3f8062

File tree

4 files changed

+29
-18
lines changed

4 files changed

+29
-18
lines changed

src/generators/jsx-ast/utils/__tests__/buildBarProps.test.mjs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ describe('buildBarProps utilities', () => {
2222
const result = buildMetaBarProps(SAMPLE, [SAMPLE]);
2323

2424
assert.equal(result.addedIn, 'v1.0.0');
25-
assert.deepEqual(result.viewAs, [['JSON', 'sample-api.json']]);
25+
assert.deepEqual(result.viewAs, [
26+
['JSON', 'sample-api.json'],
27+
['MD', 'sample-api.md'],
28+
]);
2629
assert.ok(result.readingTime.startsWith('1 min'));
2730
assert.ok(result.editThisPage.endsWith('sample-api.md'));
28-
assert.deepEqual(result.headings, [{ depth: 2, value: 'SampleFunc' }]);
31+
assert.deepEqual(result.headings, [
32+
{ depth: 2, value: 'SampleFunc', slug: 'sample-func' },
33+
]);
2934
});
3035
});
3136
});
Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

4-
import remarkParse from 'remark-parse';
5-
import remarkStringify from 'remark-stringify';
6-
import { unified } from 'unified';
7-
84
import { SAMPLE } from './utils.mjs';
9-
import { AST_NODE_TYPES } from '../../constants.mjs';
5+
import { JSX_IMPORTS } from '../../../web/constants.mjs';
106
import buildContent from '../buildContent.mjs';
117

128
describe('buildContent', () => {
139
it('should process entries and include JSX wrapper elements', () => {
14-
const processor = unified().use(remarkParse).use(remarkStringify);
15-
const tree = buildContent([SAMPLE], SAMPLE, {}, processor);
16-
17-
const article = tree.children.find(
18-
child => child.name === AST_NODE_TYPES.JSX.ARTICLE
10+
const tree = buildContent(
11+
[SAMPLE],
12+
SAMPLE,
13+
{},
14+
{
15+
runSync: x => ({
16+
body: [{ expression: x }],
17+
}),
18+
}
1919
);
20-
assert.ok(article);
21-
assert.ok(
22-
article.children.some(c => c.name === AST_NODE_TYPES.JSX.SIDE_BAR)
20+
21+
assert.deepStrictEqual(
22+
tree.children.map(child => child.name),
23+
[JSX_IMPORTS.NavBar.name, JSX_IMPORTS.Article.name]
2324
);
24-
assert.ok(article.children.some(c => c.name === AST_NODE_TYPES.JSX.FOOTER));
25+
assert.equal(tree.data, SAMPLE);
2526
});
2627
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const buildMetaBarProps = (head, entries) => {
4242
.map(entry => ({
4343
depth: entry.heading.depth,
4444
value: entry.heading.data.name,
45-
data: { id: entry.heading.data.slug },
45+
slug: entry.heading.data.slug,
4646
}));
4747

4848
return {

src/generators/web/client/components/MetaBar.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ const iconMap = {
1111
export default ({ headings, addedIn, readingTime, viewAs, editThisPage }) => (
1212
<MetaBar
1313
heading="Table of Contents"
14-
headings={{ items: headings }}
14+
headings={{
15+
items: headings.map(({ slug, ...heading }) => ({
16+
...heading,
17+
data: { id: slug },
18+
})),
19+
}}
1520
items={{
1621
'Added In': addedIn,
1722
'Reading Time': readingTime,

0 commit comments

Comments
 (0)