1import * as Namespace from "../../Namespace.ts";
2import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
3
4/** Configuration for a Prisma Astro website. */
5export interface AstroProps extends FrameworkSiteProps {
6 /** Serializable overrides merged over astro.config.*; the Node target owns adapter. */
7 astro?: {
8 /** Canonical deployment URL. */
9 site?: string;
10 /** Deployment base path. */
11 base?: string;
12 /** Render on demand or prerender every page. @default "server" */
13 output?: "server" | "static";
14 /** Source directory relative to rootDir. @default "./src" */
15 srcDir?: string;
16 /** Static passthrough directory. @default "./public" */
17 publicDir?: string;
18 /** Production output directory. @default "./dist" */
19 outDir?: string;
20 /** Route trailing-slash policy. */
21 trailingSlash?: "always" | "never" | "ignore";
22 };
23}
24
25/**
26 * Astro SSR and prerendered pages on Prisma Compute. The Node target owns the adapter; omit adapter from astro.config.*. Set astro.output to "static" to prerender every page.
27 *
28 * Native framework development and HMR run without Prisma cloud resources.
29 * Apply `Alchemy.remote()` to use the live Compute deployment during dev.
30 * Packaging requires the optional `@vercel/nft` peer dependency.
31 *
32 * ### Creating a Website
33 * **Example:** Astro application
34 * ```typescript
35 * const site = yield* Prisma.Website.Astro("Web", {
36 * rootDir: "./app",
37 * });
38 * ```
39 *
40 * ### Deployment Configuration
41 * **Example:** Existing project and custom hostname
42 * ```typescript
43 * const site = yield* Prisma.Website.Astro("Web", {
44 * project,
45 * domain: "www.example.com",
46 * env: { API_BASE: "https://api.example.com" },
47 * compute: { destroyOldDeployment: true },
48 * });
49 * ```
50 *
51 * ### Static Output
52 * **Example:** Prerendered documentation with a 404 page
53 * ```typescript
54 * const docs = yield* Prisma.Website.Astro("Docs", {
55 * rootDir: "./docs",
56 * astro: { output: "static" },
57 * assets: { notFoundHandling: "404-page" },
58 * });
59 * ```
60 *
61 * @resource
62 * @product Website
63 */
64export const Astro = (id: string, props: AstroProps = {}) =>
65 makeFrameworkSite(id, props, {
66 framework: "@alchemy.run/frontend-frameworks/astro",
67 target: "@alchemy.run/frontend-frameworks/astro/node",
68 options: {
69 astro: { ...props.astro, output: props.astro?.output ?? "server" },
70 },
71 notFoundHandling: "none",
72 }).pipe(Namespace.push(id));