@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 92 lines 3.18 KB
Raw
1 import { resolveAstroOutput } from "alchemy/Website/AstroOutput";
2 import * as Effect from "effect/Effect";
3 import { frameworkSite, staticConfigFromAssets, type FrameworkSiteProps } from "./FrameworkSite.ts";
4
5 /** The framework-integration package that drives the Astro build. */
6 export const ASTRO_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/astro";
7
8 /** The Node container deploy target for the Astro build. */
9 export const ASTRO_NODE_TARGET_SPECIFIER = "@alchemy.run/frontend-frameworks/astro/node";
10
11 export interface AstroProps extends FrameworkSiteProps {
12 /**
13 * Serializable Astro config merged OVER the project's own
14 * `astro.config.*` (which loads natively). `adapter` is owned by the Node
15 * deploy target and may not be set here.
16 */
17 astro?: {
18 /** The full URL the site deploys to (`Astro.site`). */
19 site?: string;
20 /** Base path the site deploys under. */
21 base?: string;
22 /**
23 * Astro output target. `"server"` renders pages on demand; individual
24 * pages opt into prerendering with `export const prerender = true`.
25 * `"static"` prerenders every page at build time and deploys
26 * assets-only (no SSR server). Overrides the `output` in your
27 * `astro.config.*`; leave it unset to use the file's value.
28 * @default the config file's `output`, else `"server"`
29 */
30 output?: "server" | "static";
31 /** Source directory, relative to `rootDir`. @default "./src" */
32 srcDir?: string;
33 /** Public (static passthrough) directory. @default "./public" */
34 publicDir?: string;
35 /** Build output directory. @default "./dist" */
36 outDir?: string;
37 /** Trailing-slash handling for routes. */
38 trailingSlash?: "always" | "never" | "ignore";
39 };
40 }
41
42 /**
43 * Deploy an [Astro](https://astro.build) application to Fly: a Service
44 * running the Node adapter's serve entry (static files first, then the
45 * framework handler) on port 3000.
46 *
47 * Pages render on demand by default (`output: "server"`). When your
48 * `astro.config.*` or `astro: { output: "static" }` declares a static
49 * site, every page is prerendered and the deploy is assets-only.
50 *
51 *
52 * ### Creating Astro Sites
53 * **Example:** Basic Astro App
54 * ```typescript
55 * const site = yield* Fly.Website.Astro("Web", {
56 * rootDir: "./app",
57 * });
58 * ```
59 *
60 * **Example:** Custom Domain
61 * ```typescript
62 * const site = yield* Fly.Website.Astro("Web", {
63 * rootDir: "./app",
64 * domain: "app.example.com",
65 * });
66 * ```
67 *
68 * ### Static Sites
69 * **Example:** Fully Static Astro Site
70 * ```typescript
71 * const site = yield* Fly.Website.Astro("Docs", {
72 * rootDir: "./docs",
73 * astro: { output: "static" },
74 * assets: { notFoundHandling: "404-page" },
75 * });
76 * ```
77 *
78 * @resource
79 * @product Website
80 */
81 export const Astro = (id: string, props: AstroProps = {}) =>
82 resolveAstroOutput({ rootDir: props.rootDir, output: props.astro?.output }).pipe(
83 Effect.flatMap((output) =>
84 frameworkSite(id, props, {
85 name: "Astro",
86 framework: ASTRO_FRAMEWORK_SPECIFIER,
87 target: ASTRO_NODE_TARGET_SPECIFIER,
88 options: { astro: { ...props.astro, output } },
89 static: output === "static" ? staticConfigFromAssets(props.assets) : undefined,
90 }),
91 ),
92 );