diff --git a/.github/workflows/web_cd.yaml b/.github/workflows/web_cd.yaml deleted file mode 100644 index 4cda8908e2..0000000000 --- a/.github/workflows/web_cd.yaml +++ /dev/null @@ -1,19 +0,0 @@ -on: - workflow_dispatch: - push: - paths: - - "apps/web/**" - branches: - - main -jobs: - deploy: - runs-on: ubuntu-latest - timeout-minutes: 60 - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/pnpm_install - - run: pnpm -F @hypr/web run build - - run: pnpm -F @hypr/web run deploy - env: - NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} - NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} diff --git a/apps/web/netlify.toml b/apps/web/netlify.toml index e8c4fcabb3..5570c05619 100644 --- a/apps/web/netlify.toml +++ b/apps/web/netlify.toml @@ -1,15 +1,11 @@ [build] command = "pnpm -F @hypr/web build" -publish = "dist/client" +publish = "apps/web/dist/client" [build.environment] VITE_APP_URL = "https://hyprnote.com" NODE_VERSION = "22" -[[edge_functions]] -function = "og" -path = "/og" - [images] # https://docs.netlify.com/build/image-cdn/overview/#remote-path remote_images = [ diff --git a/apps/web/netlify/edge-functions/og.tsx b/apps/web/netlify/edge-functions/og.tsx index 3027da2de8..45b90d0e6f 100644 --- a/apps/web/netlify/edge-functions/og.tsx +++ b/apps/web/netlify/edge-functions/og.tsx @@ -1,75 +1,107 @@ // deno-lint-ignore no-import-prefix import { ImageResponse } from "https://deno.land/x/og_edge@0.0.6/mod.ts"; +// deno-lint-ignore no-import-prefix +import { z } from "https://deno.land/x/zod@v3.23.8/mod.ts"; -export default function handler(req: Request) { - const url = new URL(req.url); - const title = url.searchParams.get("title") || "Hyprnote"; - const description = url.searchParams.get("description") || "AI Meeting Notes"; +const templateSchema = z.object({ + type: z.literal("meeting"), + title: z.string(), + headers: z.array(z.string()), +}); + +const OGSchema = z.discriminatedUnion("type", [templateSchema]); + +function parseSearchParams(url: URL): z.infer | null { + const type = url.searchParams.get("type"); + if (!type) { + return null; + } - return new ImageResponse( - ( + const title = url.searchParams.get("title"); + const headers = url.searchParams.getAll("headers"); + + const result = OGSchema.safeParse({ type, title, headers }); + return result.success ? result.data : null; +} + +function renderTemplate(params: z.infer) { + return ( +
-
- {title} -
-
- {description} -
-
- Hyprnote -
+ {params.title} +
+
+ {params.headers.map((header, i) => ( +
+
+ {header} +
+ ))}
- ), +
); } +export default function handler(req: Request) { + const url = new URL(req.url); + const params = parseSearchParams(url); + + if (!params) { + return new Response(JSON.stringify({ error: "invalid_parameters" }), { + status: 400, + headers: { "Content-Type": "application/json" }, + }); + } + + // https://unpic.pics/og-edge + return new ImageResponse(renderTemplate(params)); +} + +// https://docs.netlify.com/build/edge-functions/declarations/#declare-edge-functions-inline export const config = { path: "/og", cache: "manual",