Skip to content

Commit

Permalink
feat: add storyPaths page option
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Jul 3, 2020
1 parent 2ecb69b commit 563add3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion core/core/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export interface PageConfiguration {
*/
basePath?: string;

/**
* if true, generate story-based paths. This is for documents with sidebars that allow selection of stories
*/
storyPaths?: boolean;

/**
* label - used for menu labels
*/
Expand Down Expand Up @@ -82,7 +87,7 @@ type WebpackConfig = WebpackConfiguration | WebpackConfigFn;

export type PagesOnlyRoutes = Record<
PageType,
Pick<PageConfiguration, 'basePath'> & {
Pick<PageConfiguration, 'basePath' | 'storyPaths'> & {
tabs?: Pick<TabConfiguration, 'route'>[];
}
>;
Expand Down Expand Up @@ -241,6 +246,7 @@ export const defaultBuildConfig: BuildConfiguration = {
pages: {
story: {
basePath: 'docs/',
storyPaths: true,
tabs: [{ route: 'page' }, { route: 'test' }],
},
blog: {
Expand Down
5 changes: 4 additions & 1 deletion integrations/gatsby-theme-stories/src/gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ exports.createPages = async (
tabs.forEach((tab, tabIndex) => {
const route = tabIndex > 0 ? tab.route : undefined;
docs.forEach(doc => {
const stories = doc.stories?.length ? doc.stories : [undefined];
const stories =
page.storyPaths && doc.stories?.length
? doc.stories
: [undefined];
stories.forEach((storyId?: string) => {
const url = getStoryPath(
storyId,
Expand Down

0 comments on commit 563add3

Please sign in to comment.