@@ -78,7 +78,7 @@ async function renderURL(context: Context, options: PfeDevServerInternalConfig):
7878 /* Rewrite the permalink to match location of the dev server componentSubpath */
7979 demos . forEach ( demo => {
8080 if ( demo ?. permalink ) {
81- demo . permalink = demo . permalink . replace ( options . site . docsComponentSubpath , options . site . componentSubpath ) ;
81+ demo . permalink = demo . permalink . replace ( options . site . componentSubpath , options . elementsDir ) ;
8282 }
8383 } ) ;
8484 const demo = demos . find ( x => x . permalink === url . pathname ) ;
@@ -100,8 +100,7 @@ function pfeDevServerPlugin(options: PfeDevServerInternalConfig): Plugin {
100100 return {
101101 name : 'pfe-dev-server' ,
102102 async serverStart ( { fileWatcher, app } ) {
103- const { componentSubpath } = options . site ;
104- const { tagPrefix } = options ;
103+ const { elementsDir, tagPrefix } = options ;
105104
106105 const router =
107106 new Router ( )
@@ -114,29 +113,29 @@ function pfeDevServerPlugin(options: PfeDevServerInternalConfig): Plugin {
114113 ctx . type = 'application/javascript' ;
115114 } )
116115 // Redirect `elements/jazz-hands/*.js` to `elements/pf-jazz-hands/*.ts`
117- . get ( `/${ componentSubpath } /:element/:fileName.js` , async ctx => {
116+ . get ( `/${ elementsDir } /:element/:fileName.js` , async ctx => {
118117 const { element, fileName } = ctx . params ;
119- ctx . redirect ( `/${ componentSubpath } /${ element } /${ fileName } .ts` ) ;
118+ ctx . redirect ( `/${ elementsDir } /${ element } /${ fileName } .ts` ) ;
120119 } )
121120 // Redirect `elements/jazz-hands/demo/*.js|css` to `elements/pf-jazz-hands/demo/*.js|css`
122121 // If request is `elements/jazz-hands/demo/some-other-demo/*.js|css redirect files to `elements/pf-jazz-hands/demo/*.js|css`
123- . get ( `/${ componentSubpath } /:element/demo/:demoSubDir?/:fileName.:ext` , async ( ctx , next ) => {
122+ . get ( `/${ elementsDir } /:element/demo/:demoSubDir?/:fileName.:ext` , async ( ctx , next ) => {
124123 const { element, fileName, ext } = ctx . params ;
125124 if ( ! element . includes ( tagPrefix ) ) {
126- ctx . redirect ( `/${ componentSubpath } /${ tagPrefix } -${ element } /demo/${ fileName } .${ ext } ` ) ;
125+ ctx . redirect ( `/${ elementsDir } /${ tagPrefix } -${ element } /demo/${ fileName } .${ ext } ` ) ;
127126 } else {
128127 return next ( ) ;
129128 }
130129 } )
131130 // Redirect `elements/jazz-hands/*` to `elements/pf-jazz-hands/*` for files not previously handled
132- . get ( `/${ componentSubpath } /:element/:splatPath*` , async ( ctx , next ) => {
131+ . get ( `/${ elementsDir } /:element/:splatPath*` , async ( ctx , next ) => {
133132 const { element, splatPath } = ctx . params ;
134133 if ( splatPath . includes ( 'demo' ) ) {
135134 /* if its the demo directory return */
136135 return next ( ) ;
137136 }
138137 if ( ! element . includes ( tagPrefix ) ) {
139- ctx . redirect ( `/${ componentSubpath } /${ tagPrefix } -${ element } /${ splatPath } ` ) ;
138+ ctx . redirect ( `/${ elementsDir } /${ tagPrefix } -${ element } /${ splatPath } ` ) ;
140139 } else {
141140 return next ( ) ;
142141 }
0 commit comments