Skip to content

Commit cceb639

Browse files
committed
get tags from csf directly
1 parent c8fdee3 commit cceb639

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/csf/transformCsf.ts

+2-13
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,6 @@ const makeBeforeEach = (beforeEachPrefixer: FilePrefixer) => {
9292
const makeArray = (templateResult: TemplateResult) =>
9393
Array.isArray(templateResult) ? templateResult : [templateResult];
9494

95-
// copied from csf-tools, as it's not exported
96-
function parseTags(prop: t.Node) {
97-
if (!t.isArrayExpression(prop)) {
98-
throw new Error('CSF: Expected tags array');
99-
}
100-
101-
return prop.elements.map((e) => {
102-
if (t.isStringLiteral(e)) return e.value;
103-
throw new Error(`CSF: Expected tag to be string literal`);
104-
}) as string[];
105-
}
106-
10795
export const transformCsf = (
10896
code: string,
10997
{
@@ -128,7 +116,8 @@ export const transformCsf = (
128116
if (annotations?.play) {
129117
acc[key].play = annotations.play;
130118
}
131-
acc[key].tags = annotations.tags ? parseTags(annotations.tags) : csf.meta.tags || [];
119+
120+
acc[key].tags = csf._stories[key].tags || csf.meta.tags || [];
132121
return acc;
133122
}, {} as Record<string, { play?: t.Node; tags?: string[] }>);
134123

0 commit comments

Comments
 (0)