Skip to content

Commit

Permalink
build: account for styleUrl in examples generation
Browse files Browse the repository at this point in the history
Adds some logic to account for the `styleUrl` property when constructing the examples module.
  • Loading branch information
crisbeto committed Feb 26, 2024
1 parent 63a764d commit f6b5f17
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/example-module/parse-example-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export function parseExampleFile(fileName: string, content: string): ParsedMetad
const visitNode = (node: any): void => {
if (node.kind === ts.SyntaxKind.ClassDeclaration) {
const decorators = ts.getDecorators(node);
const meta: any = {
const meta = {
componentName: node.name.text,
};
} as ParsedMetadata;

if (node.jsDoc && node.jsDoc.length) {
for (const doc of node.jsDoc) {
Expand Down Expand Up @@ -68,11 +68,13 @@ export function parseExampleFile(fileName: string, content: string): ParsedMetad
meta[propName] = prop.initializer.elements.map(
literal => (literal as ts.StringLiteralLike).text,
);
} else if (propName === 'styleUrl' && ts.isStringLiteralLike(prop.initializer)) {
meta.styleUrls = [prop.initializer.text];
} else if (
ts.isStringLiteralLike(prop.initializer) ||
ts.isIdentifier(prop.initializer)
) {
meta[propName] = prop.initializer.text;
(meta as any)[propName] = prop.initializer.text;
}
}

Expand Down

0 comments on commit f6b5f17

Please sign in to comment.