diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..53ab9cb --- /dev/null +++ b/.env.example @@ -0,0 +1,20 @@ +# Public canonical URL for metadata and auth redirects. +NEXT_PUBLIC_SITE_URL= +# Supabase project URL. +NEXT_PUBLIC_SUPABASE_URL= +# Supabase anon/publishable key. +NEXT_PUBLIC_SUPABASE_ANON_KEY= +# Supabase service-role key; server only. +SUPABASE_SERVICE_ROLE_KEY= +# Shared secret for GitHub Actions API calls. +CRON_SECRET= +# Reserved for the later AI phase; unused by the foundation. +GEMINI_API_KEY= +# Reserved model name for the later writing phase. +WRITER_MODEL= +# Reserved model name for the later design phase. +DESIGNER_MODEL= +# Reserved for later workflow dispatch; unused by the foundation. +GITHUB_DISPATCH_TOKEN= +# App URL used by GitHub Actions; also add as the APP_URL repository secret. +APP_URL= diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..dc57737 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + quality: + runs-on: ubuntu-latest + env: + NEXT_PUBLIC_SITE_URL: http://localhost:3000 + NEXT_PUBLIC_SUPABASE_URL: http://127.0.0.1:54321 + NEXT_PUBLIC_SUPABASE_ANON_KEY: ci-anon-key + SUPABASE_SERVICE_ROLE_KEY: ci-service-role-key + CRON_SECRET: ci-cron-secret-at-least-32-characters-long + APP_URL: http://127.0.0.1:3000 + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version-file: .nvmrc + cache: npm + - name: Install dependencies + run: npm ci + - name: Lint + run: npm run lint + - name: Typecheck + run: npm run typecheck + - name: Build + run: npm run build diff --git a/.github/workflows/ingest.yml b/.github/workflows/ingest.yml new file mode 100644 index 0000000..add5916 --- /dev/null +++ b/.github/workflows/ingest.yml @@ -0,0 +1,41 @@ +name: Scheduled ingest + +on: + schedule: + - cron: "0 1,8,15 * * *" + workflow_dispatch: + +permissions: {} + +concurrency: + group: ingest-${{ github.ref }} + cancel-in-progress: false + +jobs: + call-ingest: + runs-on: ubuntu-latest + steps: + - name: Call the ingest stub + env: + APP_URL: ${{ secrets.APP_URL }} + CRON_SECRET: ${{ secrets.CRON_SECRET }} + run: | + if [[ -z "$APP_URL" ]]; then + echo "::notice title=Configuration::APP_URL is not set; skipping the scheduled request." + exit 0 + fi + if [[ -z "$CRON_SECRET" ]]; then + echo "::error title=Configuration::CRON_SECRET is not set." + exit 1 + fi + http_code=$(curl --silent --show-error \ + --output "$RUNNER_TEMP/ingest-response.json" \ + --write-out "%{http_code}" \ + --request POST \ + --header "Authorization: Bearer $CRON_SECRET" \ + "$APP_URL/api/cron/ingest") + cat "$RUNNER_TEMP/ingest-response.json" + if [[ ! "$http_code" =~ ^2[0-9][0-9]$ ]]; then + echo "::error title=Ingest request failed::The endpoint returned HTTP $http_code." + exit 1 + fi diff --git a/.github/workflows/latex-check.yml b/.github/workflows/latex-check.yml new file mode 100644 index 0000000..7cae823 --- /dev/null +++ b/.github/workflows/latex-check.yml @@ -0,0 +1,39 @@ +name: LaTeX check + +on: + push: + paths: + - "latex/**" + - ".github/workflows/latex-check.yml" + pull_request: + paths: + - "latex/**" + - ".github/workflows/latex-check.yml" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: latex-${{ github.ref }} + cancel-in-progress: true + +jobs: + compile-reference: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Compile the May reference + uses: xu-cheng/latex-action@v4 + with: + texlive_version: 2026 + root_file: latex/reference/may-2026.tex + work_in_root_file_dir: true + args: -pdf -file-line-error -halt-on-error -interaction=nonstopmode + - name: Upload PDF artifact + uses: actions/upload-artifact@v4 + with: + name: may-2026-reference + path: latex/reference/may-2026.pdf + if-no-files-found: error diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7ae6edd --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +# dependencies +/node_modules +/.pnp +.pnp.* + +# build output +/.next/ +/out/ +/build/ + +# local environment files (keep .env.example tracked) +.env* +!.env.example + +# Supabase local state +/supabase/.temp/ + +# debug logs +npm-debug.log* +yarn-debug.log* +pnpm-debug.log* + +# editor and OS files +.DS_Store +*.pem +.idea/ +.vscode/* +!.vscode/extensions.json + +# generated local files +/coverage/ +*.tsbuildinfo +next-env.d.ts diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..a2e8115 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +26.13.1 diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..55ee088 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "plugins": ["prettier-plugin-tailwindcss"], + "semi": true, + "singleQuote": false, + "trailingComma": "all" +} diff --git a/README.md b/README.md index 5febd9a..2e98cca 100644 --- a/README.md +++ b/README.md @@ -2,46 +2,63 @@ The newsroom behind **Machine Intelligence**, the magazine of the Department of Artificial Intelligence at NFC IET Multan. -This app is planned to gather AI news from trusted sources, group articles about the same event, and prepare short summaries for editors. Editors will review each story, approve or reject it, and build the next magazine issue as a PDF or LaTeX for Overleaf. +The foundation is in place: a public magazine site, a Supabase-backed editor allowlist, a mobile-friendly editor desk, secure API stubs, and GitHub Actions for CI, scheduled ingest calls, and LaTeX checks. The first issue and editor story cards still use clearly labeled sample data. -> **Project status:** This repository is being bootstrapped. The app, specification, environment template, and automation are not in place yet; they will be added in focused pull requests. +## Foundation status -## Planned workflow +- **Public site:** home, issue archive and issue detail, About, How it is made, Privacy, sitemap, robots, Open Graph image, and a custom not-found page. +- **Editor desk:** email magic links for emails on the editor list; Draft, Stories, Quarantine, Sources, Images, Issues, and admin-only Editors pages. +- **Supabase:** editors, editions, and runs tables; row-level security; public issues and private drafts buckets; vector extension. +- **API:** health endpoint plus authenticated ingest and compile-callback stubs. The stubs only write run records. +- **Automation:** CI checks, a three-times-daily GitHub Actions request, and a LaTeX reference compile workflow. +- **Not active yet:** RSS ingestion, Gemini calls, story clustering or scoring, draft rendering, PDF publishing, and publication logic. -1. **Collect.** Scheduled jobs read RSS feeds from trusted news sites, official company blogs, and research pages. -2. **Write.** An AI step summarizes each story with key facts and links to its sources. Facts and numbers are checked against the original articles. -3. **Review.** Editors approve or reject stories. Rejected stories go to Quarantine and can be restored. -4. **Design.** A second AI step assigns stories to positions and styles from the magazine's existing design pieces. -5. **Build.** Code turns the approved layout into LaTeX, and a GitHub Action compiles the PDF. -6. **Publish.** Once an issue is released, its stories are marked as used and the next draft starts with fresh news. +## Stack -## Planned stack +Next.js App Router, React, TypeScript, Tailwind CSS, Supabase Auth/Postgres/Storage, GitHub Actions, Vercel, and TeX Live. Gemini is reserved for a later phase. -Next.js · TypeScript · Tailwind · Supabase (Postgres, Storage, Auth) · Gemini API · GitHub Actions · TeX Live · Vercel +## Development -## Planned project layout +Use Node.js 26.13.1, matching .nvmrc. -~~~text -app/ pages and API routes -lib/ingest/ RSS, full text, and story grouping -lib/ai/ writer, designer, tone, and layout checks -lib/render/ LaTeX components and escaping -lib/score.ts story ranking -lib/select.ts draft selection -config/ magazine settings and writing style guide -supabase/migrations/ database schema -.github/workflows/ ingest, compile, and deploy +~~~bash +nvm install +nvm use +npm ci +cp .env.example .env.local +npm run dev ~~~ -## Development +The public site can show its sample preview without Supabase credentials. Sign-in, the editor desk, and API stubs need the required values in .env.local. See [the setup guide](docs/SETUP.md). + +~~~bash +npm run lint +npm run typecheck +npm run build +~~~ -The application scaffold has not been added yet, so local run instructions will follow with the first application setup pull request. A Supabase project and Gemini API key will be needed for the completed app. +## Project documents -Never commit real API keys. Use the example environment file when it is added. +- [Developer setup](docs/SETUP.md) +- [Build specification](docs/SPEC.md) +- [May 2026 LaTeX design reference](latex/reference/may-2026.tex) -## Deployment +## Project layout -The intended deployment uses Vercel for the Next.js app and GitHub Actions for scheduled jobs and PDF builds. Deployment workflows and environment setup will be added in later pull requests. +~~~text +app/ public pages, editor desk, and API routes +components/ shared site, editor, and UI components +config/ magazine identity, sections, and slot counts +content/site.ts public and editor-facing copy +lib/data/ clearly labeled sample issue and story data +lib/ingest/ phase 2 feed collection +lib/ai/ phase 2 model providers +lib/render/ later LaTeX rendering +supabase/migrations/ database schema and access policies +.github/workflows/ CI, ingest request, and LaTeX check +~~~ + +A [Coding Moves](https://codingmoves.com) project. ## Contributions diff --git a/app/(site)/about/page.tsx b/app/(site)/about/page.tsx new file mode 100644 index 0000000..d534fac --- /dev/null +++ b/app/(site)/about/page.tsx @@ -0,0 +1,79 @@ +import type { Metadata } from "next"; +import Link from "next/link"; +import { magazine } from "@/config/magazine"; +import { siteCopy } from "@/content/site"; +import { PageHeading } from "@/components/page-heading"; +import { Section } from "@/components/ui/section"; + +export const metadata: Metadata = { + title: "About", + description: siteCopy.about.intro, +}; + +export default function AboutPage() { + return ( + <> +
+ +
+
+
+
+

{siteCopy.about.purposeTitle}

+

+ {siteCopy.about.purpose} +

+
+
+
+

{siteCopy.about.supervisionTitle}

+

{magazine.supervisor.name}

+

{magazine.supervisor.title}

+

{magazine.universityShort}

+
+
+

{siteCopy.about.editorsTitle}

+
    + {magazine.editors.map((editor) => ( +
  • {editor}
  • + ))} +
+
+
+
+
+
+
+
+

{siteCopy.about.correctionTitle}

+

{siteCopy.about.correction}

+ + {siteCopy.about.correctionLink} + +
+
+

{siteCopy.about.contributionTitle}

+

{siteCopy.about.contribution}

+ + {siteCopy.about.contributionLink} + +
+
+
+ + ); +} diff --git a/app/(site)/how-its-made/page.tsx b/app/(site)/how-its-made/page.tsx new file mode 100644 index 0000000..3b71638 --- /dev/null +++ b/app/(site)/how-its-made/page.tsx @@ -0,0 +1,41 @@ +import type { Metadata } from "next"; +import { PageHeading } from "@/components/page-heading"; +import { Eyebrow } from "@/components/ui/eyebrow"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; + +export const metadata: Metadata = { + title: siteCopy.nav.process, + description: siteCopy.process.intro, +}; + +export default function HowItsMadePage() { + return ( + <> +
+ +
+
+
+ {siteCopy.process.steps.map((step) => ( +
+

{step.number}

+

{step.title}

+

{step.text}

+
+ ))} +
+
+
+
+ {siteCopy.process.ruleTitle} +

{siteCopy.process.ruleText}

+
+
+ + ); +} diff --git a/app/(site)/issues/[slug]/page.tsx b/app/(site)/issues/[slug]/page.tsx new file mode 100644 index 0000000..51491cf --- /dev/null +++ b/app/(site)/issues/[slug]/page.tsx @@ -0,0 +1,149 @@ +import type { Metadata } from "next"; +import { notFound } from "next/navigation"; +import { magazine } from "@/config/magazine"; +import { CoverArtwork } from "@/components/cover-artwork"; +import { Container } from "@/components/ui/container"; +import { EmptyState } from "@/components/ui/empty-state"; +import { Eyebrow } from "@/components/ui/eyebrow"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; +import { getIssue, getIssues } from "@/lib/data/issues"; + +type IssuePageProps = { + params: Promise<{ slug: string }>; +}; + +export async function generateStaticParams() { + const issues = await getIssues(); + return issues.map((issue) => ({ slug: issue.slug })); +} + +export async function generateMetadata({ + params, +}: IssuePageProps): Promise { + const { slug } = await params; + const issue = await getIssue(slug); + if (!issue) return { title: siteCopy.issues.unknownTitle }; + return { + title: issue.title, + description: issue.inThisIssue.join(" · "), + openGraph: { + title: issue.title, + description: issue.inThisIssue.join(" · "), + images: issue.coverUrl ? [issue.coverUrl] : ["/opengraph-image"], + }, + }; +} + +export default async function IssuePage({ params }: IssuePageProps) { + const { slug } = await params; + const issue = await getIssue(slug); + if (!issue) notFound(); + + const dateLabel = issue.date + ? new Date(issue.date).toLocaleDateString("en", { + month: "long", + year: "numeric", + timeZone: "UTC", + }) + : siteCopy.issues.dateUnknown; + + return ( + <> +
+ + {issue.coverUrl ? ( + // eslint-disable-next-line @next/next/no-img-element + + ) : ( + + )} +
+ + {issue.isMock ? siteCopy.issues.sample : siteCopy.home.issueLabel} + +

+ {issue.title} +

+

{dateLabel}

+ {issue.isMock ? ( +

+ {siteCopy.home.sampleNote} +

+ ) : null} + {issue.pdfUrl ? ( + + {siteCopy.home.pdf} + + ) : null} +
+
+
+
+ {siteCopy.home.contentsLabel} + +
+
+ {siteCopy.issues.storiesHeading} +

+ {siteCopy.issues.storiesTitle} +

+ {issue.stories.length ? ( +
+ {issue.stories.map((story) => ( +
+

+ {magazine.sections.find((section) => section.id === story.section)?.label ?? story.section} +

+

+ {story.headline} +

+

+ {story.summary} +

+
+ {story.sources.map((source) => ( + + {source.name} + + ))} +
+
+ ))} +
+ ) : ( +
+ +
+ )} +
+ + ); +} diff --git a/app/(site)/issues/page.tsx b/app/(site)/issues/page.tsx new file mode 100644 index 0000000..4409be5 --- /dev/null +++ b/app/(site)/issues/page.tsx @@ -0,0 +1,36 @@ +import type { Metadata } from "next"; +import { EmptyState } from "@/components/ui/empty-state"; +import { IssueCard } from "@/components/issue-card"; +import { PageHeading } from "@/components/page-heading"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; +import { getIssues } from "@/lib/data/issues"; + +export const metadata: Metadata = { + title: siteCopy.issues.title, + description: siteCopy.issues.description, +}; + +export default async function IssuesPage() { + const issues = await getIssues(); + + return ( +
+ +
+ {issues.length ? ( + issues.map((issue) => ) + ) : ( + + )} +
+
+ ); +} diff --git a/app/(site)/layout.tsx b/app/(site)/layout.tsx new file mode 100644 index 0000000..f8d1e07 --- /dev/null +++ b/app/(site)/layout.tsx @@ -0,0 +1,6 @@ +import type { ReactNode } from "react"; +import { SiteShell } from "@/components/site-shell"; + +export default function PublicLayout({ children }: { children: ReactNode }) { + return {children}; +} diff --git a/app/(site)/page.tsx b/app/(site)/page.tsx new file mode 100644 index 0000000..2d68bb1 --- /dev/null +++ b/app/(site)/page.tsx @@ -0,0 +1,231 @@ +import Link from "next/link"; +import { magazine } from "@/config/magazine"; +import { siteCopy } from "@/content/site"; +import { getIssues } from "@/lib/data/issues"; +import { CoverArtwork } from "@/components/cover-artwork"; +import { Button } from "@/components/ui/button"; +import { EmptyState } from "@/components/ui/empty-state"; +import { Eyebrow } from "@/components/ui/eyebrow"; +import { Section } from "@/components/ui/section"; + +function issueDate(date: string) { + return date + ? new Date(date).toLocaleDateString("en", { + month: "long", + year: "numeric", + timeZone: "UTC", + }) + : siteCopy.issues.dateUnknown; +} + +export default async function HomePage() { + const issues = await getIssues(); + const latest = issues.find((issue) => !issue.isMock); + const sample = issues.find((issue) => issue.isMock); + + return ( + <> +
+
+
+ {siteCopy.home.eyebrow} +

+ {siteCopy.home.title} +

+

+ {siteCopy.home.intro} +

+
+ + +
+
+
+ {latest?.coverUrl ? ( + // eslint-disable-next-line @next/next/no-img-element + + ) : ( + + )} +
+
+
+ +
+
+
+ {siteCopy.home.issueLabel} + {latest ? ( + <> +

+ {latest.title} +

+

{issueDate(latest.date)}

+ {latest.coverUrl ? ( + // eslint-disable-next-line @next/next/no-img-element + + ) : ( +
+ +
+ )} + {latest.pdfUrl ? ( + + {siteCopy.home.pdf} + + ) : null} + + ) : ( +
+ + {siteCopy.home.sampleButton} + + ) : undefined + } + /> +
+ )} +
+ {latest ? ( +
+

+ {siteCopy.home.contentsLabel} +

+
    + {latest.inThisIssue.map((item) => ( +
  • + {item} +
  • + ))} +
+
+ ) : sample ? ( +
+ {siteCopy.issues.sample} +

+ {sample.title} +

+
    + {sample.inThisIssue.map((item) => ( +
  • + {item} +
  • + ))} +
+

+ {siteCopy.home.sampleNote} +

+
+ ) : ( + + )} +
+
+ +
+
+
+ {siteCopy.home.coverageEyebrow} +

+ {siteCopy.home.coverageTitle} +

+
+
+ {magazine.sections.map((section, index) => ( +
+

+ 0{index + 1} +

+

{section.label}

+
+ ))} +
+
+
+ +
+
+
+ {siteCopy.home.howEyebrow} +

+ {siteCopy.home.howTitle} +

+
+
+ {siteCopy.home.steps.map((step) => ( +
+

{step.number}

+

{step.title}

+

{step.text}

+
+ ))} +
+
+
+ +
+
+
+ {siteCopy.home.closeEyebrow} +

+ {siteCopy.home.closeTitle} +

+
+ + {siteCopy.home.closeLink} + +
+
+ + ); +} diff --git a/app/(site)/privacy/page.tsx b/app/(site)/privacy/page.tsx new file mode 100644 index 0000000..83c92e7 --- /dev/null +++ b/app/(site)/privacy/page.tsx @@ -0,0 +1,39 @@ +import type { Metadata } from "next"; +import { PageHeading } from "@/components/page-heading"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; + +export const metadata: Metadata = { + title: "Privacy", + description: siteCopy.privacy.intro, +}; + +export default function PrivacyPage() { + return ( +
+ +
+
+

{siteCopy.privacy.trackingTitle}

+

{siteCopy.privacy.trackingText}

+
+
+

{siteCopy.privacy.editorTitle}

+

{siteCopy.privacy.editorText}

+
+
+

{siteCopy.privacy.storageTitle}

+

{siteCopy.privacy.storageText}

+
+
+

{siteCopy.privacy.contactTitle}

+

{siteCopy.privacy.contactText}

+
+
+
+ ); +} diff --git a/app/api/compile/callback/route.ts b/app/api/compile/callback/route.ts new file mode 100644 index 0000000..b739fe5 --- /dev/null +++ b/app/api/compile/callback/route.ts @@ -0,0 +1,34 @@ +import { getCronSecret } from "@/lib/env"; +import { recordStubRun } from "@/lib/api/record-stub-run"; +import { hasValidCronBearer } from "@/lib/security/cron-auth"; + +export const runtime = "nodejs"; +export const dynamic = "force-dynamic"; + +export async function POST(request: Request) { + let secret: string; + try { + secret = getCronSecret(); + } catch (error) { + const message = + error instanceof Error + ? error.message + : "CRON_SECRET is missing or invalid."; + return Response.json({ ok: false, error: message }, { status: 503 }); + } + + if (!hasValidCronBearer(request.headers.get("authorization"), secret)) { + return Response.json({ ok: false, error: "Unauthorized." }, { status: 401 }); + } + + try { + // TODO(phase-2): validate the compile result and store its artifacts. + const runId = await recordStubRun("compile_callback"); + return Response.json({ ok: true, runId, stub: true }); + } catch { + return Response.json( + { ok: false, error: "Could not record the compile callback." }, + { status: 503 }, + ); + } +} diff --git a/app/api/cron/ingest/route.ts b/app/api/cron/ingest/route.ts new file mode 100644 index 0000000..8cc5fed --- /dev/null +++ b/app/api/cron/ingest/route.ts @@ -0,0 +1,34 @@ +import { getCronSecret } from "@/lib/env"; +import { recordStubRun } from "@/lib/api/record-stub-run"; +import { hasValidCronBearer } from "@/lib/security/cron-auth"; + +export const runtime = "nodejs"; +export const dynamic = "force-dynamic"; + +export async function POST(request: Request) { + let secret: string; + try { + secret = getCronSecret(); + } catch (error) { + const message = + error instanceof Error + ? error.message + : "CRON_SECRET is missing or invalid."; + return Response.json({ ok: false, error: message }, { status: 503 }); + } + + if (!hasValidCronBearer(request.headers.get("authorization"), secret)) { + return Response.json({ ok: false, error: "Unauthorized." }, { status: 401 }); + } + + try { + // TODO(phase-2): fetch feeds, cluster stories, and rebuild the draft. + const runId = await recordStubRun("ingest"); + return Response.json({ ok: true, runId, stub: true }); + } catch { + return Response.json( + { ok: false, error: "Could not record the ingest run." }, + { status: 503 }, + ); + } +} diff --git a/app/api/health/route.ts b/app/api/health/route.ts new file mode 100644 index 0000000..a33f9d4 --- /dev/null +++ b/app/api/health/route.ts @@ -0,0 +1,8 @@ +export const runtime = "nodejs"; + +export function GET() { + return Response.json({ + ok: true, + time: new Date().toISOString(), + }); +} diff --git a/app/auth/callback/route.ts b/app/auth/callback/route.ts new file mode 100644 index 0000000..40efbe7 --- /dev/null +++ b/app/auth/callback/route.ts @@ -0,0 +1,61 @@ +import { NextResponse, type NextRequest } from "next/server"; +import { createSupabaseServerClient } from "@/lib/supabase/server"; + +function safeNextPath(value: string | null, origin: string) { + if (!value || !value.startsWith("/") || value.startsWith("//")) { + return "/desk"; + } + + try { + const target = new URL(value, origin); + if (target.origin !== origin) return "/desk"; + return target.pathname + target.search + target.hash; + } catch { + return "/desk"; + } +} + +export async function GET(request: NextRequest) { + const requestUrl = new URL(request.url); + const code = requestUrl.searchParams.get("code"); + const nextPath = safeNextPath( + requestUrl.searchParams.get("next"), + requestUrl.origin, + ); + const supabase = await createSupabaseServerClient(); + + if (code) { + const { error } = await supabase.auth.exchangeCodeForSession(code); + if (error) { + return NextResponse.redirect( + new URL("/login?error=sign-in-failed", requestUrl.origin), + ); + } + } + + const { + data: { user }, + error: userError, + } = await supabase.auth.getUser(); + + if (userError || !user?.email) { + return NextResponse.redirect( + new URL("/login?error=sign-in-failed", requestUrl.origin), + ); + } + + const { data: editor, error: editorError } = await supabase + .from("editors") + .select("email") + .eq("email", user.email.toLowerCase()) + .maybeSingle(); + + if (editorError || !editor) { + await supabase.auth.signOut(); + return NextResponse.redirect( + new URL("/login?error=not-editor", requestUrl.origin), + ); + } + + return NextResponse.redirect(new URL(nextPath, requestUrl.origin)); +} diff --git a/app/desk/actions.ts b/app/desk/actions.ts new file mode 100644 index 0000000..5c9e81b --- /dev/null +++ b/app/desk/actions.ts @@ -0,0 +1,110 @@ +"use server"; + +import { revalidatePath } from "next/cache"; +import { redirect } from "next/navigation"; +import { z } from "zod"; +import { siteCopy } from "@/content/site"; +import { requireAdmin } from "@/lib/auth/require-editor"; +import { createSupabaseServerClient } from "@/lib/supabase/server"; +import { createSupabaseAdminClient } from "@/lib/supabase/admin"; + +export type EditorActionState = { + message: string; + kind: "error" | "success" | ""; +}; + +const emailSchema = z.string().trim().email(); +const nameSchema = z.string().trim().min(2).max(80); + +async function verifyAdmin() { + const { user, editor } = await requireAdmin(); + return { email: user.email?.toLowerCase() ?? editor.email }; +} + +export async function addEditor( + _previousState: EditorActionState, + formData: FormData, +): Promise { + await verifyAdmin(); + + const parsedName = nameSchema.safeParse(formData.get("name")); + const parsedEmail = emailSchema.safeParse(formData.get("email")); + if (!parsedName.success || !parsedEmail.success) { + return { message: siteCopy.desk.editorInvalid, kind: "error" }; + } + + const supabase = createSupabaseAdminClient(); + const { error } = await supabase.from("editors").insert({ + email: parsedEmail.data.toLowerCase(), + name: parsedName.data, + role: "editor", + }); + + if (error?.code === "23505") { + return { message: siteCopy.desk.editorDuplicate, kind: "error" }; + } + if (error) { + return { message: siteCopy.desk.editorActionError, kind: "error" }; + } + + revalidatePath("/desk/editors"); + return { message: siteCopy.desk.editorCreated, kind: "success" }; +} + +export async function removeEditor( + _previousState: EditorActionState, + formData: FormData, +): Promise { + const actor = await verifyAdmin(); + const parsedEmail = emailSchema.safeParse(formData.get("email")); + if (!parsedEmail.success) { + return { message: siteCopy.desk.editorInvalid, kind: "error" }; + } + + const email = parsedEmail.data.toLowerCase(); + if (email === actor.email) { + return { message: siteCopy.desk.editorSelfRemove, kind: "error" }; + } + + const supabase = createSupabaseAdminClient(); + const { data: target, error: lookupError } = await supabase + .from("editors") + .select("email, role") + .eq("email", email) + .maybeSingle(); + + if (lookupError) { + return { message: siteCopy.desk.editorActionError, kind: "error" }; + } + if (!target) { + return { message: siteCopy.desk.editorNotFound, kind: "error" }; + } + + if (target.role === "admin") { + const { count, error: countError } = await supabase + .from("editors") + .select("email", { count: "exact", head: true }) + .eq("role", "admin"); + if (countError) { + return { message: siteCopy.desk.editorActionError, kind: "error" }; + } + if ((count ?? 0) <= 1) { + return { message: siteCopy.desk.editorLastAdmin, kind: "error" }; + } + } + + const { error } = await supabase.from("editors").delete().eq("email", email); + if (error) { + return { message: siteCopy.desk.editorActionError, kind: "error" }; + } + + revalidatePath("/desk/editors"); + return { message: siteCopy.desk.editorRemoved, kind: "success" }; +} + +export async function signOut() { + const supabase = await createSupabaseServerClient(); + await supabase.auth.signOut(); + revalidatePath("/", "layout"); + redirect("/"); +} diff --git a/app/desk/editors/page.tsx b/app/desk/editors/page.tsx new file mode 100644 index 0000000..f04d185 --- /dev/null +++ b/app/desk/editors/page.tsx @@ -0,0 +1,60 @@ +import { AddEditorForm, RemoveEditorForm } from "@/components/editor-management"; +import { PageHeading } from "@/components/page-heading"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; +import { requireAdmin } from "@/lib/auth/require-editor"; +import { createSupabaseAdminClient } from "@/lib/supabase/admin"; + +export default async function EditorsPage() { + const { user } = await requireAdmin(); + const admin = createSupabaseAdminClient(); + const { data: editors, error } = await admin + .from("editors") + .select("email, name, role, created_at") + .order("created_at", { ascending: true }); + + if (error) { + throw new Error("Could not load the editor list: " + error.message); + } + + const currentEmail = user.email?.toLowerCase(); + + return ( +
+ +
+ +
+ {editors.length ? ( +
+ {editors.map((editor) => ( +
+
+

{editor.name}

+

{editor.email}

+

+ {editor.role === "admin" + ? siteCopy.desk.roleAdmin + : siteCopy.desk.roleEditor} +

+
+ +
+ ))} +
+ ) : ( +

{siteCopy.desk.noEditors}

+ )} +
+ ); +} diff --git a/app/desk/images/page.tsx b/app/desk/images/page.tsx new file mode 100644 index 0000000..e2abc4d --- /dev/null +++ b/app/desk/images/page.tsx @@ -0,0 +1,28 @@ +import { PageHeading } from "@/components/page-heading"; +import { Button } from "@/components/ui/button"; +import { EmptyState } from "@/components/ui/empty-state"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; + +export default function ImagesPage() { + return ( +
+
+ + +
+
+ +
+
+ ); +} diff --git a/app/desk/issues/page.tsx b/app/desk/issues/page.tsx new file mode 100644 index 0000000..10b06c4 --- /dev/null +++ b/app/desk/issues/page.tsx @@ -0,0 +1,64 @@ +import { PageHeading } from "@/components/page-heading"; +import { EmptyState } from "@/components/ui/empty-state"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; +import { createSupabaseServerClient } from "@/lib/supabase/server"; + +export default async function IssuesPage() { + const supabase = await createSupabaseServerClient(); + const { data: editions, error } = await supabase + .from("editions") + .select("id, slug, title, status, created_at, published_at") + .order("created_at", { ascending: false }); + + if (error) { + throw new Error("Could not load editions: " + error.message); + } + + return ( +
+ +
+ {editions.length ? ( +
+ {editions.map((edition) => ( +
+
+

+ {edition.title} +

+

+ {edition.slug} ·{" "} + {new Date(edition.created_at).toLocaleDateString("en", { timeZone: "UTC" })} +

+
+ + {siteCopy.desk.editionStatus[edition.status]} + +
+ ))} +
+ ) : ( + + )} +
+
+ ); +} diff --git a/app/desk/layout.tsx b/app/desk/layout.tsx new file mode 100644 index 0000000..fa5488e --- /dev/null +++ b/app/desk/layout.tsx @@ -0,0 +1,54 @@ +import type { ReactNode } from "react"; +import Link from "next/link"; +import { DeskNavigation } from "@/components/desk-navigation"; +import { magazine } from "@/config/magazine"; +import { siteCopy } from "@/content/site"; +import { requireEditor } from "@/lib/auth/require-editor"; +import { signOut } from "@/app/desk/actions"; +import { Button } from "@/components/ui/button"; + +export default async function DeskLayout({ + children, +}: { + children: ReactNode; +}) { + const { user, editor } = await requireEditor(); + + return ( +
+ +
+
+
+

+ {siteCopy.desk.title} +

+

+ {siteCopy.desk.currentUser}: {editor.name} · {user.email} +

+
+
+ +
+
+
{children}
+
+ +
+ ); +} diff --git a/app/desk/page.tsx b/app/desk/page.tsx new file mode 100644 index 0000000..ee4a204 --- /dev/null +++ b/app/desk/page.tsx @@ -0,0 +1,82 @@ +import { siteCopy } from "@/content/site"; +import { Button } from "@/components/ui/button"; +import { Container } from "@/components/ui/container"; +import { EmptyState } from "@/components/ui/empty-state"; +import { Eyebrow } from "@/components/ui/eyebrow"; +import { Section } from "@/components/ui/section"; + +export default function DraftPage() { + const comingSoon = siteCopy.desk.comingSoon; + + return ( + <> +
+ + {siteCopy.desk.draftTitle} +
+
+

+ {siteCopy.desk.draftTitle} +

+

+ {siteCopy.desk.lastUpdated} +

+
+
+ + + + +
+
+
+
+ +
+ +
+
+

+ {siteCopy.desk.preview} +

+ {comingSoon} +
+
+ +
+
+
+
+ + ); +} diff --git a/app/desk/quarantine/page.tsx b/app/desk/quarantine/page.tsx new file mode 100644 index 0000000..b22ea49 --- /dev/null +++ b/app/desk/quarantine/page.tsx @@ -0,0 +1,24 @@ +import { PageHeading } from "@/components/page-heading"; +import { QuarantineBoard } from "@/components/quarantine-board"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; +import { mockStories } from "@/lib/data/mock-stories"; + +export default function QuarantinePage() { + const rejectedStories = mockStories.filter( + (story) => story.status === "rejected", + ); + + return ( +
+ +
+ +
+
+ ); +} diff --git a/app/desk/sources/page.tsx b/app/desk/sources/page.tsx new file mode 100644 index 0000000..8db763b --- /dev/null +++ b/app/desk/sources/page.tsx @@ -0,0 +1,20 @@ +import { PageHeading } from "@/components/page-heading"; +import { SourcesTable } from "@/components/sources-table"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; +import { mockSources } from "@/lib/data/mock-sources"; + +export default function SourcesPage() { + return ( +
+ +
+ +
+
+ ); +} diff --git a/app/desk/stories/page.tsx b/app/desk/stories/page.tsx new file mode 100644 index 0000000..7422993 --- /dev/null +++ b/app/desk/stories/page.tsx @@ -0,0 +1,20 @@ +import { PageHeading } from "@/components/page-heading"; +import { StoryBoard } from "@/components/story-board"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; +import { mockStories } from "@/lib/data/mock-stories"; + +export default function StoriesPage() { + return ( +
+ +
+ +
+
+ ); +} diff --git a/app/globals.css b/app/globals.css new file mode 100644 index 0000000..daaa93f --- /dev/null +++ b/app/globals.css @@ -0,0 +1,73 @@ +@import "tailwindcss"; + +:root { + --paper: #f9f7f1; + --ink: #18352e; + --leaf-dark: #1c5745; + --leaf: #347763; + --muted: #587067; + --line: #dbe1d6; + --sun: #f2c46e; + --mist: #e9efe6; + --band: #1a3a31; +} + +@theme inline { + --color-paper: var(--paper); + --color-ink: var(--ink); + --color-leaf-dark: var(--leaf-dark); + --color-leaf: var(--leaf); + --color-muted: var(--muted); + --color-line: var(--line); + --color-sun: var(--sun); + --color-mist: var(--mist); + --color-band: var(--band); + --font-sans: var(--font-inter), system-ui, sans-serif; + --font-serif: Georgia, "Times New Roman", serif; +} + +* { + box-sizing: border-box; +} + +html { + scroll-behavior: smooth; +} + +body { + min-height: 100vh; + background: var(--paper); + color: var(--ink); + font-family: var(--font-inter), system-ui, sans-serif; + text-rendering: optimizeLegibility; +} + +h1, +h2, +h3, +h4 { + font-family: Georgia, "Times New Roman", serif; + font-weight: 400; + letter-spacing: -0.035em; +} + +:focus-visible { + outline: 3px solid var(--leaf); + outline-offset: 3px; +} + +::selection { + background: var(--mist); + color: var(--ink); +} + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + scroll-behavior: auto !important; + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + } +} diff --git a/app/icon.svg b/app/icon.svg new file mode 100644 index 0000000..efd1ad0 --- /dev/null +++ b/app/icon.svg @@ -0,0 +1,4 @@ + + + ✦ + diff --git a/app/layout.tsx b/app/layout.tsx new file mode 100644 index 0000000..1d6af8b --- /dev/null +++ b/app/layout.tsx @@ -0,0 +1,46 @@ +import type { Metadata } from "next"; +import { Inter } from "next/font/google"; +import type { ReactNode } from "react"; +import { magazine } from "@/config/magazine"; +import { siteCopy } from "@/content/site"; +import "./globals.css"; + +const inter = Inter({ + subsets: ["latin"], + display: "swap", + variable: "--font-inter", +}); + +export const metadata: Metadata = { + metadataBase: new URL( + process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000", + ), + title: { + default: siteCopy.seo.title, + template: "%s | " + magazine.name, + }, + description: + siteCopy.seo.description, + applicationName: magazine.name, + openGraph: { + type: "website", + siteName: magazine.name, + title: siteCopy.seo.title, + description: + siteCopy.seo.description, + }, + twitter: { + card: "summary_large_image", + title: siteCopy.seo.title, + description: + siteCopy.seo.description, + }, +}; + +export default function RootLayout({ children }: { children: ReactNode }) { + return ( + + {children} + + ); +} diff --git a/app/login/actions.ts b/app/login/actions.ts new file mode 100644 index 0000000..8efea20 --- /dev/null +++ b/app/login/actions.ts @@ -0,0 +1,56 @@ +"use server"; + +import { z } from "zod"; +import { siteCopy } from "@/content/site"; +import { getPublicEnv } from "@/lib/env"; +import { createSupabaseAdminClient } from "@/lib/supabase/admin"; +import { createSupabaseServerClient } from "@/lib/supabase/server"; + +export type LoginActionState = { + message: string; + kind: "error" | "success" | ""; +}; + +export async function sendMagicLink( + _previousState: LoginActionState, + formData: FormData, +): Promise { + const parsedEmail = z.string().trim().email().safeParse(formData.get("email")); + if (!parsedEmail.success) { + return { message: siteCopy.login.invalidEmail, kind: "error" }; + } + + const email = parsedEmail.data.toLowerCase(); + const admin = createSupabaseAdminClient(); + const { data: editor, error: lookupError } = await admin + .from("editors") + .select("email") + .eq("email", email) + .maybeSingle(); + + if (lookupError) { + return { message: siteCopy.login.checkInbox, kind: "success" }; + } + if (!editor) { + return { message: siteCopy.login.checkInbox, kind: "success" }; + } + + const { NEXT_PUBLIC_SITE_URL } = getPublicEnv(); + const callbackUrl = new URL("/auth/callback", NEXT_PUBLIC_SITE_URL); + callbackUrl.searchParams.set("next", "/desk"); + + const supabase = await createSupabaseServerClient(); + const { error } = await supabase.auth.signInWithOtp({ + email, + options: { + emailRedirectTo: callbackUrl.toString(), + shouldCreateUser: true, + }, + }); + + if (error) { + return { message: siteCopy.login.checkInbox, kind: "success" }; + } + + return { message: siteCopy.login.checkInbox, kind: "success" }; +} diff --git a/app/login/login-form.tsx b/app/login/login-form.tsx new file mode 100644 index 0000000..cecca21 --- /dev/null +++ b/app/login/login-form.tsx @@ -0,0 +1,50 @@ +"use client"; + +import { useActionState } from "react"; +import type { LoginActionState } from "@/app/login/actions"; +import { sendMagicLink } from "@/app/login/actions"; +import { siteCopy } from "@/content/site"; +import { Button } from "@/components/ui/button"; + +const initialState: LoginActionState = { message: "", kind: "" }; + +export function LoginForm() { + const [state, formAction, pending] = useActionState( + sendMagicLink, + initialState, + ); + + return ( +
+ + +
+ +
+

+ {state.message} +

+
+ ); +} diff --git a/app/login/page.tsx b/app/login/page.tsx new file mode 100644 index 0000000..cbf1abf --- /dev/null +++ b/app/login/page.tsx @@ -0,0 +1,53 @@ +import type { Metadata } from "next"; +import Link from "next/link"; +import { SiteShell } from "@/components/site-shell"; +import { PageHeading } from "@/components/page-heading"; +import { Section } from "@/components/ui/section"; +import { siteCopy } from "@/content/site"; +import { LoginForm } from "@/app/login/login-form"; + +type LoginPageProps = { + searchParams: Promise<{ error?: string }>; +}; + +export const metadata: Metadata = { + title: siteCopy.login.title, + description: siteCopy.login.intro, + robots: { index: false, follow: false }, +}; + +export default async function LoginPage({ searchParams }: LoginPageProps) { + const { error } = await searchParams; + const errorMessage = + error === "not-editor" + ? siteCopy.login.notEditor + : error === "admin-required" + ? siteCopy.desk.adminRequired + : error === "sign-in-failed" + ? siteCopy.login.genericError + : null; + + return ( + +
+ + {errorMessage ? ( +

+ {errorMessage} +

+ ) : null} + + + {siteCopy.login.back} + +
+
+ ); +} diff --git a/app/not-found.tsx b/app/not-found.tsx new file mode 100644 index 0000000..ae44c66 --- /dev/null +++ b/app/not-found.tsx @@ -0,0 +1,29 @@ +import Link from "next/link"; +import { SiteShell } from "@/components/site-shell"; +import { siteCopy } from "@/content/site"; +import { Eyebrow } from "@/components/ui/eyebrow"; +import { Section } from "@/components/ui/section"; + +export default function NotFound() { + return ( + +
+
+ {siteCopy.notFound.eyebrow} +

+ {siteCopy.notFound.title} +

+

+ {siteCopy.notFound.description} +

+ + {siteCopy.notFound.returnHome} + +
+
+
+ ); +} diff --git a/app/opengraph-image.tsx b/app/opengraph-image.tsx new file mode 100644 index 0000000..2bb5020 --- /dev/null +++ b/app/opengraph-image.tsx @@ -0,0 +1,61 @@ +import { ImageResponse } from "next/og"; +import { magazine } from "@/config/magazine"; +import { siteCopy } from "@/content/site"; + +export const alt = siteCopy.seo.ogAlt; +export const size = { width: 1200, height: 630 }; +export const contentType = "image/png"; + +export default function OpenGraphImage() { + return new ImageResponse( + ( +
+
+ {magazine.departmentShort} · {magazine.universityShort} +
+
+
+ {magazine.name} +
+
+ {siteCopy.home.intro} +
+
+
+ {siteCopy.seo.ogFooter} +
+
+ ), + size, + ); +} diff --git a/app/robots.ts b/app/robots.ts new file mode 100644 index 0000000..0b3d826 --- /dev/null +++ b/app/robots.ts @@ -0,0 +1,13 @@ +import type { MetadataRoute } from "next"; + +export default function robots(): MetadataRoute.Robots { + const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000"; + return { + rules: { + userAgent: "*", + allow: "/", + disallow: ["/desk", "/api/"], + }, + sitemap: new URL("/sitemap.xml", siteUrl).toString(), + }; +} diff --git a/app/sitemap.ts b/app/sitemap.ts new file mode 100644 index 0000000..d841e9d --- /dev/null +++ b/app/sitemap.ts @@ -0,0 +1,30 @@ +import type { MetadataRoute } from "next"; +import { getIssues } from "@/lib/data/issues"; + +export default async function sitemap(): Promise { + const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "http://localhost:3000"; + const staticPaths = [ + "", + "/issues", + "/about", + "/how-its-made", + "/privacy", + ]; + const staticEntries = staticPaths.map((path) => ({ + url: new URL(path, siteUrl).toString(), + lastModified: new Date("2026-11-16T00:00:00.000Z"), + changeFrequency: "monthly" as const, + priority: path === "" ? 1 : 0.7, + })); + const issues = await getIssues(); + const issueEntries = issues + .filter((issue) => !issue.isMock && issue.date) + .map((issue) => ({ + url: new URL("/issues/" + issue.slug, siteUrl).toString(), + lastModified: new Date(issue.date), + changeFrequency: "yearly" as const, + priority: 0.6, + })); + + return [...staticEntries, ...issueEntries]; +} diff --git a/components/cover-artwork.tsx b/components/cover-artwork.tsx new file mode 100644 index 0000000..4549e37 --- /dev/null +++ b/components/cover-artwork.tsx @@ -0,0 +1,45 @@ +import { magazine } from "@/config/magazine"; +import { siteCopy } from "@/content/site"; + +export function CoverArtwork({ + compact = false, + issueTitle = siteCopy.cover.headline, + issueDate = siteCopy.cover.referenceDate, + sample = true, +}: { + compact?: boolean; + issueTitle?: string; + issueDate?: string; + sample?: boolean; +}) { + return ( +
+
+ {magazine.name} + {issueDate} +
+
+

+ {magazine.departmentShort} +

+

+ {issueTitle} +

+

+ {sample ? siteCopy.cover.note : siteCopy.cover.previewNote} +

+
+
+ {magazine.universityShort} + {sample ? siteCopy.cover.label : siteCopy.cover.issueLabel} +
+
+ ); +} diff --git a/components/desk-navigation.tsx b/components/desk-navigation.tsx new file mode 100644 index 0000000..7af0341 --- /dev/null +++ b/components/desk-navigation.tsx @@ -0,0 +1,57 @@ +"use client"; + +import Link from "next/link"; +import { usePathname } from "next/navigation"; +import type { EditorRole } from "@/lib/supabase/types"; +import { siteCopy } from "@/content/site"; + +export function DeskNavigation({ + role, + mobile = false, +}: { + role: EditorRole; + mobile?: boolean; +}) { + const pathname = usePathname(); + const links = siteCopy.desk.nav.filter( + (item) => !("adminOnly" in item) || !item.adminOnly || role === "admin", + ); + + return ( + + ); +} diff --git a/components/editor-management.tsx b/components/editor-management.tsx new file mode 100644 index 0000000..2088770 --- /dev/null +++ b/components/editor-management.tsx @@ -0,0 +1,104 @@ +"use client"; + +import { useActionState } from "react"; +import { addEditor, removeEditor } from "@/app/desk/actions"; +import type { EditorActionState } from "@/app/desk/actions"; +import type { EditorRole } from "@/lib/supabase/types"; +import { siteCopy } from "@/content/site"; +import { Button } from "@/components/ui/button"; + +const initialState: EditorActionState = { message: "", kind: "" }; + +export type EditorRow = { + email: string; + name: string; + role: EditorRole; + created_at: string; +}; + +function ActionMessage({ state }: { state: EditorActionState }) { + if (!state.message) return null; + return ( +

+ {state.message} +

+ ); +} + +export function AddEditorForm() { + const [state, formAction, pending] = useActionState(addEditor, initialState); + + return ( +
+ + +
+ +
+

+ {siteCopy.desk.editorAddHelp} +

+
+ +
+
+ ); +} + +export function RemoveEditorForm({ + email, + disabled = false, +}: { + email: string; + disabled?: boolean; +}) { + const [state, formAction, pending] = useActionState(removeEditor, initialState); + + return ( +
+
+ + +
+ +
+ ); +} diff --git a/components/issue-card.tsx b/components/issue-card.tsx new file mode 100644 index 0000000..448bf81 --- /dev/null +++ b/components/issue-card.tsx @@ -0,0 +1,76 @@ +import Link from "next/link"; +import type { Issue } from "@/lib/types"; +import { CoverArtwork } from "@/components/cover-artwork"; +import { siteCopy } from "@/content/site"; + +export function IssueCard({ issue }: { issue: Issue }) { + const dateLabel = issue.isMock + ? siteCopy.issues.sampleDate + : issue.date + ? new Date(issue.date).toLocaleDateString("en", { + month: "long", + year: "numeric", + timeZone: "UTC", + }) + : siteCopy.issues.dateUnknown; + + return ( +
+ + {issue.coverUrl ? ( + // eslint-disable-next-line @next/next/no-img-element + + ) : ( + + )} + +
+

{dateLabel}

+ {issue.isMock ? ( +

+ {siteCopy.issues.sample} +

+ ) : null} +

+ + {issue.title} + +

+
    + {issue.inThisIssue.slice(0, 4).map((item) => ( +
  • {item}
  • + ))} +
+
+ + {siteCopy.issues.open} + + {issue.pdfUrl ? ( + + {siteCopy.home.pdf} + + ) : null} +
+
+
+ ); +} diff --git a/components/page-heading.tsx b/components/page-heading.tsx new file mode 100644 index 0000000..a8f0811 --- /dev/null +++ b/components/page-heading.tsx @@ -0,0 +1,23 @@ +import { Eyebrow } from "@/components/ui/eyebrow"; + +export function PageHeading({ + eyebrow, + title, + description, +}: { + eyebrow: string; + title: string; + description: string; +}) { + return ( +
+ {eyebrow} +

+ {title} +

+

+ {description} +

+
+ ); +} diff --git a/components/quarantine-board.tsx b/components/quarantine-board.tsx new file mode 100644 index 0000000..a1ffb19 --- /dev/null +++ b/components/quarantine-board.tsx @@ -0,0 +1,56 @@ +"use client"; + +import { useState } from "react"; +import type { Story } from "@/lib/types"; +import { Button } from "@/components/ui/button"; +import { EmptyState } from "@/components/ui/empty-state"; +import { StatusChip } from "@/components/ui/status-chip"; +import { siteCopy } from "@/content/site"; + +export function QuarantineBoard({ initialStories }: { initialStories: Story[] }) { + const [stories, setStories] = useState(initialStories); + + function restore(storyId: string) { + setStories((current) => current.filter((story) => story.id !== storyId)); + } + + if (!stories.length) { + return ( + + ); + } + + return ( +
+ {stories.map((story) => ( +
+
+
+ +
+

{story.headline}

+

{story.summary}

+

+ {siteCopy.desk.reason}:{" "} + {story.rejectReason} +

+
+ +
+ ))} +

{siteCopy.desk.localOnly}

+
+ ); +} diff --git a/components/site-footer.tsx b/components/site-footer.tsx new file mode 100644 index 0000000..3b6b9f7 --- /dev/null +++ b/components/site-footer.tsx @@ -0,0 +1,36 @@ +import Link from "next/link"; +import { Container } from "@/components/ui/container"; +import { magazine } from "@/config/magazine"; +import { siteCopy } from "@/content/site"; + +export function SiteFooter() { + return ( +
+ +

+ © {magazine.copyrightYear} {siteCopy.footer.copyright} · {siteCopy.footer.builtBy} +

+ +
+
+ ); +} diff --git a/components/site-header.tsx b/components/site-header.tsx new file mode 100644 index 0000000..ef892c2 --- /dev/null +++ b/components/site-header.tsx @@ -0,0 +1,54 @@ +import Link from "next/link"; +import { magazine } from "@/config/magazine"; +import { siteCopy } from "@/content/site"; +import { Container } from "@/components/ui/container"; + +const links = [ + { href: "/issues", label: siteCopy.nav.issues }, + { href: "/about", label: siteCopy.nav.about }, + { href: "/how-its-made", label: siteCopy.nav.process }, +]; + +export function SiteHeader() { + return ( +
+ + + + {magazine.name} + + + + {magazine.universityShort} · {magazine.departmentShort} + + + + +
+ ); +} diff --git a/components/site-shell.tsx b/components/site-shell.tsx new file mode 100644 index 0000000..f5d1bee --- /dev/null +++ b/components/site-shell.tsx @@ -0,0 +1,20 @@ +import type { ReactNode } from "react"; +import { SiteFooter } from "@/components/site-footer"; +import { SiteHeader } from "@/components/site-header"; +import { siteCopy } from "@/content/site"; + +export function SiteShell({ children }: { children: ReactNode }) { + return ( + <> + + {siteCopy.nav.skip} + + +
{children}
+ + + ); +} diff --git a/components/sources-table.tsx b/components/sources-table.tsx new file mode 100644 index 0000000..537980a --- /dev/null +++ b/components/sources-table.tsx @@ -0,0 +1,51 @@ +import { siteCopy } from "@/content/site"; +import type { Source } from "@/lib/types"; + +export function SourcesTable({ sources }: { sources: Source[] }) { + if (!sources.length) { + return

{siteCopy.desk.sourcesEmpty}

; + } + + return ( +
+ + + + + + + + + + + + {sources.map((source) => ( + + + + + + + + ))} + +
{siteCopy.desk.sourceName}{siteCopy.desk.sourceRegionLabel}{siteCopy.desk.sourceType}{siteCopy.desk.trustWeight}{siteCopy.desk.activeSource}
+ + {source.name} + +

{siteCopy.desk.feedPending}

+
+ {siteCopy.desk.sourceRegion[source.region]} + + {siteCopy.desk.sourceKind[source.kind]} + + {source.trustWeight.toFixed(1)} + {siteCopy.desk.activeSource}
+
+ ); +} diff --git a/components/story-board.tsx b/components/story-board.tsx new file mode 100644 index 0000000..af25aa3 --- /dev/null +++ b/components/story-board.tsx @@ -0,0 +1,200 @@ +"use client"; + +import { useState, type FormEvent } from "react"; +import { magazine } from "@/config/magazine"; +import { siteCopy } from "@/content/site"; +import type { Story } from "@/lib/types"; +import { Button } from "@/components/ui/button"; +import { EmptyState } from "@/components/ui/empty-state"; +import { StatusChip } from "@/components/ui/status-chip"; + +export function StoryBoard({ initialStories }: { initialStories: Story[] }) { + const [stories, setStories] = useState(initialStories); + const [editing, setEditing] = useState<{ + id: string; + headline: string; + summary: string; + } | null>(null); + + function saveEdit(event: FormEvent) { + event.preventDefault(); + if (!editing) return; + setStories((current) => + current.map((story) => + story.id === editing.id + ? { + ...story, + headline: editing.headline.trim() || story.headline, + summary: editing.summary.trim() || story.summary, + } + : story, + ), + ); + setEditing(null); + } + + function setStatus(storyId: string, status: "approved" | "rejected") { + setStories((current) => + current.map((story) => + story.id === storyId + ? { + ...story, + status, + rejectReason: + status === "rejected" + ? siteCopy.desk.rejectedLocally + : undefined, + } + : story, + ), + ); + } + + const visibleStories = stories.filter((story) => story.status !== "rejected"); + + if (!visibleStories.length) { + return ( + + ); + } + + return ( +
+ {magazine.sections.map((section) => { + const sectionStories = visibleStories.filter( + (story) => story.section === section.id, + ); + if (!sectionStories.length) return null; + + return ( +
+
+

+ {section.label} +

+

+ {sectionStories.length} / {section.slots} +

+
+
+ {sectionStories.map((story) => { + const isEditing = editing?.id === story.id; + return ( +
+ {isEditing && editing ? ( +
+ +