Skip to main content
Glama
storybookv5.ts1.52 kB
export type StorybookData = { v: 5; entries: { [key: string]: { type: string; id: string; name: string; title: string; importPath: string; tags: string[]; }; }; }; export const getComponentList = (data: StorybookData) => { if (!data || data.v !== 5 || !data.entries) { return []; } const entries = data.entries; // extract component names, filter only docs type entries const components = Object.values(entries) .filter((entry) => entry.type === "docs") .map((entry) => entry.title) .filter((title: string) => title) .sort(); // remove duplicates const uniqueComponents = [...new Set(components)]; return uniqueComponents; }; export const getComponentPropsDocUrl = ( data: StorybookData, componentName: string, storybookUrl: string ) => { if (!data || data.v !== 5 || !data.entries) { return null; } const entries = data.entries || {}; // find matching component entry const matchingEntry = Object.values(entries).find( (entry) => entry.type === "docs" && entry.title === componentName ); if (!matchingEntry) { throw new Error(`Component "${componentName}" not found in Storybook`); } const [fileName] = new URL(storybookUrl).pathname.split("/").slice(-1); // build component documentation page URL const baseUrl = storybookUrl.replace(`/${fileName}`, ""); const componentUrl = `${baseUrl}/iframe.html?viewMode=${matchingEntry.type}&id=${matchingEntry.id}`; return componentUrl; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mcpland/storybook-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server