Skip to content

Commit e4448e7

Browse files
authored
docs: add configuration for component's more examples (#3747)
1 parent eb9ca32 commit e4448e7

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

docs/component-docs-plugin/generatePageMDX.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
const config = require('../docusaurus.config');
22

3-
const { baseUrl } = config;
3+
const { baseUrl, customFields } = config;
4+
5+
function generateMoreExamples(componentName) {
6+
const componentMoreExamples = customFields.moreExamples[componentName];
7+
8+
if (!componentMoreExamples) {
9+
return `<span />`;
10+
}
11+
12+
const links = Object.entries(componentMoreExamples)
13+
.map(([key, value]) => {
14+
return `
15+
<li key="${key}">
16+
<a href="${value}">${key}</a>
17+
</li>
18+
`;
19+
})
20+
.join('');
21+
22+
return `
23+
## More Examples
24+
<details>
25+
<summary>Toggle to grab more examples</summary>
26+
<ul>
27+
${links}
28+
</ul>
29+
</details>
30+
`;
31+
}
432

533
function generatePageMDX(doc, link) {
634
const description = doc.description
@@ -17,6 +45,8 @@ import PropTable from '@site/src/components/PropTable.tsx';
1745
1846
${description}
1947
48+
${generateMoreExamples(doc.title)}
49+
2050
## Props
2151
2252
<PropTable link="${link}" />

docs/docusaurus.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,15 @@ const config = {
289289
indexName: 'crawler_React Native Paper Docs',
290290
},
291291
}),
292+
293+
customFields: {
294+
moreExamples: {
295+
Portal: {
296+
'Comprehensive Portal example':
297+
'https://snack.expo.dev/@react-native-paper/comprehensive-portal-example',
298+
},
299+
},
300+
},
292301
};
293302

294303
module.exports = config;

0 commit comments

Comments
 (0)