@andersundsehr/storybook-typo3
Version:
The one and only Storybook Renderer for TYPO3 Fluid Components
18 lines (17 loc) • 709 B
JavaScript
import { url } from '@andersundsehr/storybook-typo3';
import { fetchWithUserRetry } from './fetchWithUserRetry';
export async function fetchComponent(component) {
if (!component.includes(':')) {
const message = 'Component name must be in the format "namespace:name"';
alert(message);
throw new Error(message);
}
const data = await fetchWithUserRetry(url + '/_storybook/componentMeta?viewHelper=' + component, {}, 'metadata for component `' + component + '`');
return {
fullName: component,
name: component.split(':')[1],
namespace: component.split(':')[0],
collection: data.collectionClassName,
argTypes: data.argTypes,
};
}