Skip to content

Commit 60e3c42

Browse files
committed
Update npm package page creation story file check to include multiple file locations
1 parent e59c125 commit 60e3c42

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

web/src/lib/create-npm-package-pages.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ module.exports = async (actions, graphql) => {
2424
throw result.errors;
2525
}
2626

27+
function hasStorybookConfig(relPath) {
28+
const locations = ['stories/index.js', 'storybook/index.js', 'storybook/index.jsx'];
29+
30+
return locations.some((location) => {
31+
const filePath = path.join(relPath, location);
32+
return fs.existsSync(filePath);
33+
});
34+
}
35+
2736
result.data.npmPackages.edges.map(({ node }) => {
2837
// Package manifest slug will be /package so remove it
2938
const pagePath = path.dirname(node.fields.slug);
@@ -41,7 +50,7 @@ module.exports = async (actions, graphql) => {
4150
packageName: node.manifest.name,
4251
packageDescription: node.manifest.description,
4352
// Flag if Storybook demos are available for this package
44-
storybook: fs.existsSync(path.join(relPath, 'stories', 'index.js')),
53+
storybook: hasStorybookConfig(relPath),
4554
// Associate readme and story nodes via slug
4655
packagePath: path.join(pagePath, 'package'),
4756
readmePath: path.join(pagePath, 'readme')

0 commit comments

Comments
 (0)