@storybook/addon-svelte-csf 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as svelte from 'svelte/compiler';
|
|
2
|
-
import { storyNameFromExport, toId } from '@storybook/csf';
|
|
3
2
|
import dedent from 'dedent';
|
|
4
3
|
import { extractId } from './extract-id.js';
|
|
5
4
|
function getStaticAttribute(name, node) {
|
|
@@ -85,7 +84,6 @@ export function extractStories(component) {
|
|
|
85
84
|
source = dedent `${component.substr(start, end - start)}`;
|
|
86
85
|
}
|
|
87
86
|
stories[isTemplate ? `tpl:${id}` : id] = {
|
|
88
|
-
storyId: toId(meta.id || meta.title || id, storyNameFromExport(id)),
|
|
89
87
|
name,
|
|
90
88
|
template: isTemplate,
|
|
91
89
|
source,
|
package/dist/preset/indexer.d.ts
CHANGED
package/dist/preset/indexer.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as svelte from 'svelte/compiler';
|
|
|
2
2
|
import { extractStories } from '../parser/extract-stories.js';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import { loadSvelteConfig } from '../config-loader.js';
|
|
5
|
+
import { storyNameFromExport, toId } from '@storybook/csf';
|
|
5
6
|
export async function svelteIndexer(fileName, { makeTitle }) {
|
|
6
7
|
let code = (await fs.readFile(fileName, 'utf-8')).toString();
|
|
7
8
|
const svelteOptions = await loadSvelteConfig();
|
|
@@ -9,12 +10,13 @@ export async function svelteIndexer(fileName, { makeTitle }) {
|
|
|
9
10
|
code = (await svelte.preprocess(code, svelteOptions.preprocess, { filename: fileName })).code;
|
|
10
11
|
}
|
|
11
12
|
const defs = extractStories(code);
|
|
13
|
+
const meta = { ...defs.meta, title: makeTitle(defs.meta.title) };
|
|
12
14
|
return {
|
|
13
|
-
meta
|
|
15
|
+
meta,
|
|
14
16
|
stories: Object.entries(defs.stories)
|
|
15
17
|
.filter(([id, story]) => !story.template)
|
|
16
18
|
.map(([id, story]) => ({
|
|
17
|
-
id:
|
|
19
|
+
id: toId(meta.id || meta.title || id, storyNameFromExport(id)),
|
|
18
20
|
name: story.name,
|
|
19
21
|
})),
|
|
20
22
|
};
|