diff --git a/app/api/ads/slots/[id]/install-embed/route.ts b/app/api/ads/slots/[id]/install-embed/route.ts index 65d77da8..5aa76c84 100644 --- a/app/api/ads/slots/[id]/install-embed/route.ts +++ b/app/api/ads/slots/[id]/install-embed/route.ts @@ -15,6 +15,7 @@ import { createClient } from "@/lib/supabase/server"; import { serviceClient } from "@/lib/supabase/service"; import { getOrMintInstallationToken } from "@/lib/github/installations"; import { installAdEmbed } from "@/lib/github/install-ad"; +import { AD_FORMAT_IDS } from "@/lib/ads/formats"; export const runtime = "nodejs"; @@ -23,6 +24,8 @@ const bodySchema = z.object({ repo: z.string().min(1).optional(), installation_id: z.number().int().positive().optional(), target_path: z.string().max(500).optional(), + // Which ad size to install. Defaults to the medium rectangle in the installer. + format: z.enum(AD_FORMAT_IDS as [string, ...string[]]).optional(), }); type BoundRepo = { @@ -141,6 +144,7 @@ export async function POST(request: NextRequest, ctx: { params: Promise<{ id: st owner: owner!, repo: repo!, slotId, + format: body.format, targetPath: body.target_path, }); await finalize({ diff --git a/components/ads/slot-manager.tsx b/components/ads/slot-manager.tsx index ea476215..01a1ad50 100644 --- a/components/ads/slot-manager.tsx +++ b/components/ads/slot-manager.tsx @@ -3,6 +3,13 @@ import { useState, useTransition } from "react"; import { useRouter } from "next/navigation"; import { createSlot, setSlotStatus, saveSlotPayout, requestPayout } from "@/app/actions/ads"; +import { PUBLISHER_FORMAT_IDS, formatSpec, type AdFormatId } from "@/lib/ads/formats"; + +// The paste-once embed for a given size. data-format tells /ad.js which creative +// to request; the medium rectangle stays the default the auto-installer uses. +function embedFor(slotId: string, format: AdFormatId, origin: string): string { + return `
\n`; +} type Project = { id: string; name: string; url: string }; type Slot = { @@ -73,15 +80,16 @@ export function SlotManager({ const [addr, setAddr] = useState(slot?.payout_address ?? ""); const [currency, setCurrency] = useState(slot?.payout_currency ?? "usdc_pol"); const [copied, setCopied] = useState(false); + // Which size's embed is currently revealed, and whether the code block is open. + const [fmt, setFmt] = useState
- {embed}
-
-
+ {embed}
+
+