Skip to content

Commit

Permalink
fix: prevent TITLE from being parsed as a story
Browse files Browse the repository at this point in the history
Signed-off-by: Lu Nelson <lunelson@gmail.com>
  • Loading branch information
lunelson committed Jan 1, 2025
1 parent 215defd commit 5bda641
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const getNamedExports = (
},
astPath,
) => {
if (!astPath?.node?.declaration && !astPath?.node?.specifiers) return;

/**
* @param {any} namedExportDeclaration
* @param {string} namedExport
Expand Down Expand Up @@ -79,7 +81,10 @@ const getNamedExports = (
if (namedExportDeclaration.type === "ClassDeclaration") {
namedExport = namedExportDeclaration.id.name;
} else if (namedExportDeclaration.type === "VariableDeclaration") {
namedExport = namedExportDeclaration.declarations[0].id.name;
// Skip TITLE constant export
const declaration = namedExportDeclaration.declarations[0];
if (declaration.id.name === "TITLE") return;
namedExport = declaration.id.name;
} else if (namedExportDeclaration.type === "FunctionDeclaration") {
namedExport = namedExportDeclaration.id.name;
} else {
Expand All @@ -94,6 +99,8 @@ const getNamedExports = (
astPath.node?.specifiers.forEach(
/** type * @param {any} specifier */
(specifier) => {
// Skip TITLE export
if (specifier.exported.name === "TITLE") return;
const namedExport = specifier.exported.name;
const story = namedExportToStory(specifier, namedExport);
stories.push(story);
Expand Down

0 comments on commit 5bda641

Please sign in to comment.