[英]Sorting in Storybook: Possible to force an order for nested stories?
My Storybook uses the following grouping for stories:我的故事书对故事使用以下分组:
Introduction
Styleguide
Atoms
Component
📄 README
📁 Examples
Component
📄 README
📁 Examples
Molecules
Component
📄 README
📁 Examples
Organisms
Component
📄 README
📁 Examples
I'm currently sorting stories like this:我目前正在整理这样的故事:
options: {
storySort: {
method: 'alphabetical',
order: ['Introduction', 'Styleguide', 'Atoms', 'Molecules', 'Organisms'],
locales: 'en-US',
}
},
This gets me close , but the README and Examples within component stories appear in alphabetical order when I want README to appear first.这让我很接近,但是当我希望自述文件首先出现时,组件故事中的自述文件和示例会按字母顺序出现。
Is this possible?这可能吗?
I had a similar problem, and I could find a way of doing as you requested, after finding this info on the storybook documentation :我遇到了类似的问题,在故事书文档中找到此信息后,我可以找到按照您的要求进行操作的方法:
For your specific case, I think that you could do something like this:对于您的具体情况,我认为您可以执行以下操作:
options: {
storySort: {
method: 'alphabetical',
order: ['Introduction', 'Styleguide', 'Atoms', ['Readme', '*'], 'Molecules', ['Readme', '*'], 'Organisms', ['Readme', '*']],
locales: 'en-US',
}
},
Basically, you just have to add , ['Readme', '*']
after every group that you like to sort by using the Readme first
custom order.基本上,您只需要在您喜欢使用
Readme first
自定义顺序排序的每个组之后添加, ['Readme', '*']
。 This just indicates storybook to display the Readme
story first, and then the rest of the stories.这只是指示 storybook 首先显示
Readme
故事,然后显示其余的故事。
This approach solves the problem, but I think that the solution could be improved by writing your own storySort functions, as indicated on this comment in github这种方法解决了问题,但我认为可以通过编写自己的 storySort 函数来改进解决方案,如github 中的此评论所示
I hope this answer would be helpful for your scenario too.我希望这个答案对你的场景也有帮助。
Regards问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.