Skip to content

Commit

Permalink
Indexer 2
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold committed Oct 27, 2022
1 parent 3b47bc0 commit 81d0ea4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"lint": "eslint --cache --cache-location=.cache/eslint --ext .js,.jsx,.json,.html,.ts,.tsx,.mjs --report-unused-disable-directives",
"storybook": "sb dev -p 6006",
"start": "concurrently \"yarn storybook -- --no-manager-cache --quiet\" \"yarn build -- --watch\"",
"build-storybook": "build-storybook",
"build-storybook": "sb build",
"release": "yarn build && auto shipit"
},
"dependencies": {
Expand Down
26 changes: 14 additions & 12 deletions src/preset/indexer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { extractStories } from "../parser/extract-stories";
import { extractStories } from '../parser/extract-stories';
import fs from 'fs-extra';

export async function svelteIndexer (fileName, { makeTitle }) {
let code = (await fs.readFile(fileName, 'utf-8')).toString();
export async function svelteIndexer(fileName, { makeTitle }) {
let code = (await fs.readFile(fileName, 'utf-8')).toString();

const defs = extractStories(code);
const defs = extractStories(code);

return {
meta: { title: makeTitle(defs.meta.title) },
stories: Object.entries(defs.stories).filter(e => !e[1].template).map( ([id, story])=> ({
id: story.storyId,
name: story.name
}))
}
}
return {
meta: { title: makeTitle(defs.meta.title) },
stories: Object.entries(defs.stories)
.filter(([id, story]) => !story.template)
.map(([id, story]) => ({
id: story.storyId,
name: story.name,
})),
};
}

0 comments on commit 81d0ea4

Please sign in to comment.