Addon-docs: Fix custom source manual override

This commit is contained in:
Michael Shilman 2020-05-04 17:16:36 +08:00
parent eac63d4178
commit c79904302b
2 changed files with 14 additions and 2 deletions

View File

@ -41,7 +41,7 @@ export const getSourceProps = (
source = targetIds
.map((sourceId) => {
const data = storyStore.fromId(sourceId);
const enhanced = data && enhanceSource(data);
const enhanced = data && (enhanceSource(data) || data.parameters);
return enhanced?.docs?.source?.code || '';
})
.join('\n\n');

View File

@ -28,11 +28,23 @@ How you like them apples?!
## Custom source
<Preview>
<Story name="custom source" height="100px" parameters={{ docs: { source: { code: 'hello' }}}}>
<Story name="custom source" height="100px" parameters={{ docs: { source: { code: 'hello' } } }}>
{'<h1>Custom source</h1>'}
</Story>
</Preview>
## Transformed source
<Preview>
<Story
name="transformed source"
height="100px"
parameters={{ docs: { transformSource: (src) => `transformed: ${src}` } }}
>
{'<h1>Some source</h1>'}
</Story>
</Preview>
## Story reference
You can also reference an existing story from within your MDX file.