Skip to content

Commit 5bda641

Browse files
committed
fix: prevent TITLE from being parsed as a story
Signed-off-by: Lu Nelson <lunelson@gmail.com>
1 parent 215defd commit 5bda641

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/ladle/lib/cli/vite-plugin/parse/get-named-exports.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const getNamedExports = (
2323
},
2424
astPath,
2525
) => {
26+
if (!astPath?.node?.declaration && !astPath?.node?.specifiers) return;
27+
2628
/**
2729
* @param {any} namedExportDeclaration
2830
* @param {string} namedExport
@@ -79,7 +81,10 @@ const getNamedExports = (
7981
if (namedExportDeclaration.type === "ClassDeclaration") {
8082
namedExport = namedExportDeclaration.id.name;
8183
} else if (namedExportDeclaration.type === "VariableDeclaration") {
82-
namedExport = namedExportDeclaration.declarations[0].id.name;
84+
// Skip TITLE constant export
85+
const declaration = namedExportDeclaration.declarations[0];
86+
if (declaration.id.name === "TITLE") return;
87+
namedExport = declaration.id.name;
8388
} else if (namedExportDeclaration.type === "FunctionDeclaration") {
8489
namedExport = namedExportDeclaration.id.name;
8590
} else {
@@ -94,6 +99,8 @@ const getNamedExports = (
9499
astPath.node?.specifiers.forEach(
95100
/** type * @param {any} specifier */
96101
(specifier) => {
102+
// Skip TITLE export
103+
if (specifier.exported.name === "TITLE") return;
97104
const namedExport = specifier.exported.name;
98105
const story = namedExportToStory(specifier, namedExport);
99106
stories.push(story);

0 commit comments

Comments
 (0)