| 1 | import { Vite, type ViteProps } from "./Vite.ts"; |
| 2 | |
| 3 | export interface FoldkitProps extends ViteProps {} |
| 4 | |
| 5 | /** |
| 6 | * Deploy a [Foldkit](https://foldkit.dev) app to a Hetzner Cloud Server. |
| 7 | * |
| 8 | * Foldkit apps are client-only Vite projects, so this composite is the |
| 9 | * Vite site with SPA fallback to `index.html` (deep links boot the app |
| 10 | * and the Foldkit router takes over). |
| 11 | * |
| 12 | * |
| 13 | * ### Creating Foldkit Sites |
| 14 | * **Example:** Foldkit App |
| 15 | * ```typescript |
| 16 | * const site = yield* Hetzner.Website.Foldkit("Website"); |
| 17 | * ``` |
| 18 | * |
| 19 | * **Example:** Project in a Subdirectory |
| 20 | * ```typescript |
| 21 | * const site = yield* Hetzner.Website.Foldkit("Website", { |
| 22 | * rootDir: "applications/web", |
| 23 | * }); |
| 24 | * ``` |
| 25 | * |
| 26 | * ### Single-Page Application Routing |
| 27 | * **Example:** Serving a real 404 page |
| 28 | * ```typescript |
| 29 | * const site = yield* Hetzner.Website.Foldkit("Website", { |
| 30 | * assets: { notFoundHandling: "404-page" }, |
| 31 | * }); |
| 32 | * ``` |
| 33 | * |
| 34 | * @resource |
| 35 | * @product Website |
| 36 | */ |
| 37 | export const Foldkit = (id: string, props: FoldkitProps = {}) => |
| 38 | Vite(id, { |
| 39 | ...props, |
| 40 | assets: { |
| 41 | notFoundHandling: "single-page-application", |
| 42 | ...props.assets, |
| 43 | }, |
| 44 | }); |