@@ -348,7 +348,8 @@ export class CsfFile {
348348 const meta : StaticMeta = { } ;
349349 ( declaration . properties as t . ObjectProperty [ ] ) . forEach ( ( p ) => {
350350 if ( t . isIdentifier ( p . key ) ) {
351- this . _metaAnnotations [ p . key . name ] = p . value ;
351+ const value = t . isObjectMethod ( p ) ? p : p . value ;
352+ this . _metaAnnotations [ p . key . name ] = value ;
352353
353354 if ( p . key . name === 'title' ) {
354355 meta . title = this . _parseTitle ( p . value ) ;
@@ -598,30 +599,35 @@ export class CsfFile {
598599 // CSF3 object export
599600 ( storyNode . properties as t . ObjectProperty [ ] ) . forEach ( ( p ) => {
600601 if ( t . isIdentifier ( p . key ) ) {
601- if ( p . key . name === 'render' ) {
602- parameters . __isArgsStory = isArgsStory (
603- p . value as t . Expression ,
604- parent ,
605- self
606- ) ;
607- } else if ( p . key . name === 'name' && t . isStringLiteral ( p . value ) ) {
608- name = p . value . value ;
609- } else if ( p . key . name === 'storyName' && t . isStringLiteral ( p . value ) ) {
610- logger . warn (
611- `Unexpected usage of "storyName" in "${ exportName } ". Please use "name" instead.`
612- ) ;
613- } else if ( p . key . name === 'parameters' && t . isObjectExpression ( p . value ) ) {
614- const idProperty = p . value . properties . find (
615- ( property ) =>
616- t . isObjectProperty ( property ) &&
617- t . isIdentifier ( property . key ) &&
618- property . key . name === '__id'
619- ) as t . ObjectProperty | undefined ;
620- if ( idProperty ) {
621- parameters . __id = ( idProperty . value as t . StringLiteral ) . value ;
602+ const key = p . key . name ;
603+ if ( t . isObjectMethod ( p ) ) {
604+ self . _storyAnnotations [ exportName ] [ key ] = p ;
605+ } else {
606+ if ( p . key . name === 'render' ) {
607+ parameters . __isArgsStory = isArgsStory (
608+ p . value as t . Expression ,
609+ parent ,
610+ self
611+ ) ;
612+ } else if ( p . key . name === 'name' && t . isStringLiteral ( p . value ) ) {
613+ name = p . value . value ;
614+ } else if ( p . key . name === 'storyName' && t . isStringLiteral ( p . value ) ) {
615+ logger . warn (
616+ `Unexpected usage of "storyName" in "${ exportName } ". Please use "name" instead.`
617+ ) ;
618+ } else if ( p . key . name === 'parameters' && t . isObjectExpression ( p . value ) ) {
619+ const idProperty = p . value . properties . find (
620+ ( property ) =>
621+ t . isObjectProperty ( property ) &&
622+ t . isIdentifier ( property . key ) &&
623+ property . key . name === '__id'
624+ ) as t . ObjectProperty | undefined ;
625+ if ( idProperty ) {
626+ parameters . __id = ( idProperty . value as t . StringLiteral ) . value ;
627+ }
622628 }
629+ self . _storyAnnotations [ exportName ] [ p . key . name ] = p . value ;
623630 }
624- self . _storyAnnotations [ exportName ] [ p . key . name ] = p . value ;
625631 }
626632 } ) ;
627633 } else {
0 commit comments