Skip to content

Commit f6b5f17

Browse files
committed
build: account for styleUrl in examples generation
Adds some logic to account for the `styleUrl` property when constructing the examples module.
1 parent 63a764d commit f6b5f17

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/example-module/parse-example-file.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export function parseExampleFile(fileName: string, content: string): ParsedMetad
2222
const visitNode = (node: any): void => {
2323
if (node.kind === ts.SyntaxKind.ClassDeclaration) {
2424
const decorators = ts.getDecorators(node);
25-
const meta: any = {
25+
const meta = {
2626
componentName: node.name.text,
27-
};
27+
} as ParsedMetadata;
2828

2929
if (node.jsDoc && node.jsDoc.length) {
3030
for (const doc of node.jsDoc) {
@@ -68,11 +68,13 @@ export function parseExampleFile(fileName: string, content: string): ParsedMetad
6868
meta[propName] = prop.initializer.elements.map(
6969
literal => (literal as ts.StringLiteralLike).text,
7070
);
71+
} else if (propName === 'styleUrl' && ts.isStringLiteralLike(prop.initializer)) {
72+
meta.styleUrls = [prop.initializer.text];
7173
} else if (
7274
ts.isStringLiteralLike(prop.initializer) ||
7375
ts.isIdentifier(prop.initializer)
7476
) {
75-
meta[propName] = prop.initializer.text;
77+
(meta as any)[propName] = prop.initializer.text;
7678
}
7779
}
7880

0 commit comments

Comments
 (0)