@@ -72,17 +72,30 @@ module.exports = {
7272 } ) ;
7373 eleventyConfig . addPassthroughCopy ( 'brand/**/*' ) ;
7474
75- // Copy only screenshot.png from each element's docs/ folder to the site.
76- // Markdown docs are handled by 11ty templates; screenshots are the only static asset.
75+ // Copy static assets (screenshots, demo images/css/js) from element folders
76+ // to the site with the tag prefix stripped from the directory name.
77+ // Markdown and HTML are handled by 11ty templates; this covers everything else.
7778 const prefix = `${ ( options ?. prefix ?? 'pf' ) . replace ( / - $ / , '' ) } -` ;
7879 for ( const dir of fs . readdirSync ( path . join ( process . cwd ( ) , 'elements' ) ) ) {
80+ const slug = dir . replace ( prefix , '' ) ;
7981 const screenshot = path . join ( 'elements' , dir , 'docs' , 'screenshot.png' ) ;
8082 if ( fs . existsSync ( screenshot ) ) {
81- const slug = dir . replace ( prefix , '' ) ;
8283 eleventyConfig . addPassthroughCopy ( {
8384 [ screenshot ] : `/components/${ slug } /docs/screenshot.png` ,
8485 } ) ;
8586 }
87+ const demoDir = path . join ( process . cwd ( ) , 'elements' , dir , 'demo' ) ;
88+ if ( fs . existsSync ( demoDir ) ) {
89+ const assets =
90+ fs . readdirSync ( demoDir , { recursive : true } )
91+ . filter ( f => ! String ( f ) . endsWith ( '.html' ) ) ;
92+ for ( const asset of assets ) {
93+ const src = path . join ( 'elements' , dir , 'demo' , String ( asset ) ) ;
94+ eleventyConfig . addPassthroughCopy ( {
95+ [ src ] : `/components/${ slug } /demo/${ asset } ` ,
96+ } ) ;
97+ }
98+ }
8699 }
87100
88101 const filesToCopy = getFilesToCopy ( options ) ;
0 commit comments