Skip to content

Commit

Permalink
fix(storyblok): add component / blok classification
Browse files Browse the repository at this point in the history
  • Loading branch information
julrich committed Jan 29, 2024
1 parent f59ab35 commit 8bf8f96
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
17 changes: 17 additions & 0 deletions src/commands/cms/storyblok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ const storyblok = new Command('storyblok')
chalkTemplate`components to classify as global components`,
['header', 'footer', 'seo']
)
.option(
'--components <componentNames...>',
chalkTemplate`components to classify as bloks`,
[
'cta',
'faq',
'features',
'gallery',
'image-text',
'logos',
'stats',
'teaser-card',
'testimonials',
'text',
]
)
.option(
'--rc-only',
chalkTemplate`only read configuration from {bold .schema-storyblokrc.json}, skip prompts`,
Expand All @@ -50,6 +66,7 @@ const storyblok = new Command('storyblok')
options.updateConfig,
options.templates,
options.globals,
options.components,
options.rcOnly,
options.revert,
options.cleanup,
Expand Down
15 changes: 14 additions & 1 deletion src/tasks/cms/storyblok-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ const run = async (
updateConfig: boolean = true,
templates: string[] = ['page', 'blog-post', 'blog-overview', 'settings'],
globals: string[] = ['header', 'footer', 'seo'],
components: string[] = [
'cta',
'faq',
'features',
'gallery',
'image-text',
'logos',
'stats',
'teaser-card',
'testimonials',
'text',
],
rcOnly: boolean,
isRevert: boolean,
shouldCleanup: boolean,
Expand All @@ -62,7 +74,8 @@ const run = async (
const elements = await schemaToStoryblok(
customSchemaGlob,
templates,
globals
globals,
components
);

shell.mkdir('-p', `${shell.pwd()}/${configurationPath}/`);
Expand Down
7 changes: 5 additions & 2 deletions src/util/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ ${convertedTs[schemaId]}
const toStoryblok = async (
schemaGlob: string,
templates: string[],
globals: string[]
globals: string[],
components: string[]
) => {
const ajv = getSchemaRegistry();
const schemaIds = await processSchemaGlob(schemaGlob, ajv);
Expand All @@ -206,8 +207,10 @@ ${convertedTs[schemaId]}
return IClassifierResult.Template;
} else if (globals && globals.includes(name)) {
return IClassifierResult.Global;
} else {
} else if (components && components.includes(name)) {
return IClassifierResult.Component;
} else {
return IClassifierResult.Object;
}
},
});
Expand Down
3 changes: 2 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ interface SchemaUtil {
toStoryblok: (
schemaGlob: string,
templates: string[],
globals: string[]
globals: string[],
components: string[]
) => Promise<CMSResult<IStoryblokBlock>>;
toStoryblokConfig: (elements: CMSResult<IStoryblokBlock>) => string;
toUniform: (
Expand Down

0 comments on commit 8bf8f96

Please sign in to comment.