@@ -625,6 +625,7 @@ function validateExtension(extension: Extension) {
625625 extension . contributes . formats ,
626626 extension . contributes . project ,
627627 extension . contributes [ kRevealJSPlugins ] ,
628+ extension . contributes . metadata ,
628629 ] ;
629630 contribs . forEach ( ( contrib ) => {
630631 if ( contrib ) {
@@ -783,23 +784,30 @@ async function readExtension(
783784 return resolveFilterPath ( extensionDir , filter ) ;
784785 } ,
785786 ) ;
786- const project = ( contributes ?. project || { } ) as Record < string , unknown > ;
787- // resolve project pre- and post-render scripts to their full path
787+ const project = contributes ?. project as Record < string , unknown > | undefined ;
788+ const metadata = contributes ?. metadata as Record < string , unknown > | undefined ;
789+
790+ // resolve metadata/project pre- and post-render scripts to their full path
788791 for ( const key of [ "pre-render" , "post-render" ] ) {
789- if (
790- project . project &&
791- ( project . project as Record < string , unknown > ) [ key ]
792- ) {
793- const t = ( project . project as Record < string , unknown > ) [ key ] ;
794- const value = ( Array . isArray ( t ) ? t : [ t ] ) as string [ ] ;
795- const resolved = resolvePathGlobs (
796- extensionDir ,
797- value as string [ ] ,
798- [ ] ,
799- ) ;
800- if ( resolved . include . length > 0 ) {
801- ( project . project as Record < string , unknown > ) [ key ] = resolved
802- . include ;
792+ for ( const object of [ metadata , project ] ) {
793+ if ( ! object ?. project || typeof object . project !== "object" ) {
794+ continue ;
795+ }
796+ // object.project is truthy and typeof object.project is object
797+ // so we can safely cast object.project to Record<string, unknown>
798+ // the TypeScript checker doesn't appear to recognize this
799+ const t = ( object . project as Record < string , unknown > ) [ key ] ;
800+ if ( t ) {
801+ const value = ( Array . isArray ( t ) ? t : [ t ] ) as string [ ] ;
802+ const resolved = resolvePathGlobs (
803+ extensionDir ,
804+ value as string [ ] ,
805+ [ ] ,
806+ ) ;
807+ if ( resolved . include . length > 0 ) {
808+ ( object . project as Record < string , unknown > ) [ key ] = resolved
809+ . include ;
810+ }
803811 }
804812 }
805813 }
@@ -818,6 +826,7 @@ async function readExtension(
818826 id : extensionId ,
819827 path : extensionDir ,
820828 contributes : {
829+ metadata,
821830 shortcodes,
822831 filters,
823832 formats,
0 commit comments