1import * as Namespace from "../../Namespace.ts";
2import { makeFrameworkSite, type FrameworkSiteProps } from "./FrameworkSite.ts";
3
4/** The framework-integration package that drives the Nuxt build. */
5export const NUXT_FRAMEWORK_SPECIFIER = "@alchemy.run/frontend-frameworks/nuxt";
6
7/** The Node container deploy target for the Nuxt build. */
8export const NUXT_NODE_TARGET_SPECIFIER =
9 "@alchemy.run/frontend-frameworks/nuxt/node";
10
11export interface NuxtProps extends FrameworkSiteProps {
12 /**
13 * Nuxt config overrides merged over the project's own `nuxt.config.ts`
14 * (highest-priority layer). `nitro.preset` is owned by the Node deploy
15 * target and may not be set here.
16 */
17 nuxt?: Record<string, unknown>;
18}
19
20/**
21 * Deploy a Nuxt application to a Hetzner Cloud Server: the nitro Node
22 * server as a systemd unit on port 3000, static assets baked into the
23 * unit.
24 *
25 * The build runs through `@alchemy.run/frontend-frameworks/nuxt` with the
26 * `@alchemy.run/frontend-frameworks/nuxt/node` deploy target (`nitro.preset`
27 * `"node"`).
28 *
29 *
30 * ### Creating Nuxt Sites
31 * **Example:** Basic Nuxt App
32 * ```typescript
33 * const site = yield* Hetzner.Website.Nuxt("Web", {
34 * rootDir: "./app",
35 * });
36 * ```
37 *
38 * **Example:** Custom Domain
39 * ```typescript
40 * const site = yield* Hetzner.Website.Nuxt("Web", {
41 * rootDir: "./app",
42 * domain: "app.example.com",
43 * zone,
44 * });
45 * ```
46 *
47 * @resource
48 * @product Website
49 */
50export const Nuxt = (id: string, props: NuxtProps = {}) =>
51 makeFrameworkSite(id, props, {
52 name: "Nuxt",
53 framework: NUXT_FRAMEWORK_SPECIFIER,
54 target: NUXT_NODE_TARGET_SPECIFIER,
55 options: props.nuxt ? { nuxt: props.nuxt } : undefined,
56 }).pipe(Namespace.push(id));