Skip to content

Commit

Permalink
refactor filter function for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
JReinhold committed Oct 27, 2022
1 parent 6f5977c commit 9b95d2b
Showing 1 changed file with 14 additions and 12 deletions.
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 9b95d2b

Please sign in to comment.