also looking at this
feat(layouts): honour a fallback layouts directory
#1942
5 files
+174
-10
| @@ -537,6 +537,15 @@ export interface ServeOptions { | ||
| 537 | 537 | openPath?: string |
| 538 | 538 | componentsDir?: string |
| 539 | 539 | layoutsDir?: string |
| 540 | /** | |
| 541 | * Layouts to fall back to when `layoutsDir` does not have the one a page | |
| 542 | * asks for, so a framework can ship defaults an app overrides by name. | |
| 543 | * | |
| 544 | * Stacks has been passing this since the views server was written; until | |
| 545 | * stx honoured it, it did nothing, and every page extending a framework | |
| 546 | * layout served a 200 with an empty body. | |
| 547 | */ | |
| 548 | fallbackLayoutsDir?: string | |
| 540 | 549 | partialsDir?: string |
| 541 | 550 | /** |
| 542 | 551 | * Additional source directories that can affect rendered HTML. |
| @@ -1015,6 +1024,7 @@ export async function serve(options: ServeOptions): Promise<void> { | ||
| 1015 | 1024 | // Options passed directly take precedence, then bunfig config, then defaults |
| 1016 | 1025 | const componentsDir = options.componentsDir ?? stxConfig.componentsDir ?? defaultStxConfig.componentsDir |
| 1017 | 1026 | const layoutsDir = options.layoutsDir ?? stxConfig.layoutsDir ?? defaultStxConfig.layoutsDir |
| 1027 | const fallbackLayoutsDir = options.fallbackLayoutsDir ?? stxConfig.fallbackLayoutsDir | |
| 1018 | 1028 | const partialsDir = options.partialsDir ?? stxConfig.partialsDir ?? defaultStxConfig.partialsDir |
| 1019 | 1029 | const publicDir = options.publicDir ?? stxConfig.publicDir ?? 'public' |
| 1020 | 1030 | |
| @@ -2203,6 +2213,7 @@ function __stxOverlay(errs){ | ||
| 2203 | 2213 | root: process.cwd(), |
| 2204 | 2214 | ...(componentsDir && { componentsDir }), |
| 2205 | 2215 | ...(layoutsDir && { layoutsDir }), |
| 2216 | ...(fallbackLayoutsDir && { fallbackLayoutsDir }), | |
| 2206 | 2217 | ...(partialsDir && { partialsDir }), |
| 2207 | 2218 | autoShell: true, |
| 2208 | 2219 | buildMode: 'serve' as const, |
| @@ -2576,6 +2587,7 @@ function __stxOverlay(errs){ | ||
| 2576 | 2587 | root: process.cwd(), |
| 2577 | 2588 | ...(componentsDir && { componentsDir }), |
| 2578 | 2589 | ...(layoutsDir && { layoutsDir }), |
| 2590 | ...(fallbackLayoutsDir && { fallbackLayoutsDir }), | |
| 2579 | 2591 | ...(partialsDir && { partialsDir }), |
| 2580 | 2592 | autoShell: true, |
| 2581 | 2593 | buildMode: 'serve' as const, |
| @@ -3164,6 +3176,7 @@ function __stxOverlay(errs){ | ||
| 3164 | 3176 | ...defaultConfig, |
| 3165 | 3177 | ...(componentsDir && { componentsDir }), |
| 3166 | 3178 | ...(layoutsDir && { layoutsDir }), |
| 3179 | ...(fallbackLayoutsDir && { fallbackLayoutsDir }), | |
| 3167 | 3180 | ...(partialsDir && { partialsDir }), |
| 3168 | 3181 | autoShell: false, |
| 3169 | 3182 | } |