diff --git a/.claude/rules/database.md b/.claude/rules/database.md new file mode 100644 index 0000000..34569c7 --- /dev/null +++ b/.claude/rules/database.md @@ -0,0 +1,90 @@ +--- +paths: + - "src/collections/**" + - "src/payload.config.ts" + - "src/migrations/**" +--- + +# Database Rules + +Payload generates the Postgres schema from the collection config in `src/collections/`. The schema is designed by choosing fields, not by writing tables. These rules are non-negotiable. A PR that breaks one is rejected. + +## Ownership + +- **Payload owns** the `payload_*` tables (`payload_migrations`, `payload_preferences`, `payload_locked_documents`, `payload_kv` and their `_rels`), `users_sessions`, and the `id`, `created_at` and `updated_at` columns on every table. Never write to them, alter them or query them from site code. They hold `jsonb` and generic `_rels` joins; that is Payload's business and exempt from the rules below. +- **We own** every collection: its fields, names, constraints and access. +- Read and write through Payload's local API (`getPayload`, `payload.find`). Reach for `payload.db.drizzle` only for a query the local API cannot express, and say why in the PR. + +## Normalisation + +- **3NF.** Every field depends on the document it sits on, the whole document and nothing but the document. +- **Don't store anything derivable.** Whether a tour date is past or upcoming comes from `eventDate` at render time. An embed URL comes from the stored ID. Never add a field the page can compute. +- **Atomic columns only.** These field types are banned in our collections: + - `json`: one `jsonb` column. + - `richText`: Lexical state, one `jsonb` column. Use `textarea` for multi-line copy and lyrics. + - `blocks`: one table per block type hanging off one field, a polymorphic list. Never set `blocksAsJSON` on the adapter either. + - `point`: a PostGIS `geometry` column holding two values. + - `hasMany` on `text` or `number`: stored in generic `_texts` and `_numbers` tables keyed by a text `path`. Use an `array`. + - Any delimited or encoded text (no "a,b,c" in a `text` field). +- **Repeating data** is an `array` field. Payload stores it as a child table `_` keyed by parent and order, with a real foreign key. +- **Controlled redundancy** is allowed only when the database keeps it consistent, through a constraint or trigger in a hand-written migration. Site code never syncs a redundant value. Every case goes in the register at the end of this file. + +## Relationships + +- **No polymorphic relationships.** `relationTo` is always one collection slug, never an array. +- **No `hasMany` on `relationship` or `upload` fields.** Payload stores those in a generic `_rels` table with one nullable column per target and a text `path`, so nothing guarantees a row points where the field says. For many-to-many, use an `array` field holding one single `relationship`, or a join collection with two single relationships. +- A single `relationship` or `upload` becomes a `_id` column with a foreign key. That is the only shape we use. +- Check the generated migration: a `_rels`, `_texts` or `_numbers` table for one of our collections means a rule was broken. + +## Languages + +- The site is English and French. Translatable text uses Payload localisation: `localization: { locales: ['en', 'fr'], defaultLocale: 'en', fallback: true }` in the config and `localized: true` on the field. Payload moves those columns to `_locales`, one row per document per locale. +- Never pair fields by language (`titleEn` and `titleFr`, `lyrics` and `paroles`). +- Language-neutral data stays unlocalised: dates, URLs, venue and city names, embed IDs, images. +- Read with the visitor's locale and `fallbackLocale: 'en'`. + +## Enums, lookups and checks + +- A fixed option set that carries only a name is a `select` field. Payload creates a Postgres enum `enum__`; changing the options needs a migration. `hasMany` on a `select` is fine: it becomes a child table of enum values. +- A lookup is its own collection, and only when the options carry extra attributes or editors must add options without a deploy. State the reason in the PR. +- `required`, `unique` and `index` on a field become `NOT NULL`, a unique index and an index. Use them; they are the first line of integrity. +- Two cases drop the `NOT NULL` silently: a collection with `versions.drafts` on (every required column becomes nullable, because a draft may be incomplete) and a required field with `admin.condition`. Don't put `admin.condition` on a required field. Turning drafts on is a departure: record it in the register. +- Numeric ranges and cross-field rules that must hold for direct SQL too go in a `CHECK` constraint in a hand-written migration. Rules that only shape editor input go in the field's `validate`. + +## Naming + +- Collection slugs are plural kebab-case (`tour-dates`); Payload snake-cases them for tables. Field names are camelCase. +- Don't set `dbName` unless a generated name exceeds Postgres's 63 characters. +- IDs are Payload's default serial integers. Don't switch `idType` once data exists. + +## Access + +- Every collection declares `access.read` explicitly, so who can read it is visible in the file. Payload's access functions are the only row-level security here. +- `read: () => true` only for content the public site shows; otherwise `read: ({ req }) => Boolean(req.user)`. Leave `create`, `update` and `delete` unset: Payload's default is signed-in users only. +- The `users` collection is never publicly readable. + +## Migrations + +- `src/migrations/` is written by `pnpm exec payload migrate:create ` and applied by `pnpm exec payload migrate`. One concern per migration. +- Read the generated SQL before committing it. Reject `jsonb` and `geometry` columns and `_rels`, `_texts` and `_numbers` tables on our collections. +- Hand-written SQL (triggers, functions, `CHECK` constraints, partial indexes) goes in its own blank migration: `pnpm exec payload migrate:create --force-accept-warning`, run when no config change is pending (otherwise the file is not blank). Never mix it into a generated one. The one exception is a rename: Payload generates a drop and an add, which loses data, so replace those statements with `ALTER TABLE … RENAME` in the generated file and say so in the PR. Payload's generator does not know these objects exist, so a later rename can orphan them: list each one in the register below. +- Never edit a migration after it has merged. A migration must work with the previous deploy still running. +- `pnpm dev` pushes the schema straight to whatever `DATABASE_URL` points at. `.env.local` must point at the Neon `dev` branch, never `preview` or `main`. Those two change only through `payload migrate`. +- `src/payload-types.ts` and `src/app/(payload)/admin/importMap.js` are generated. Regenerate (`payload generate:types`, `payload generate:importmap`); never hand-edit. The other files in `src/app/(payload)/` were copied in once from Payload's template and are left alone, except `custom.scss`, which is ours to edit. Derive every content type in site code from `payload-types.ts`. + +## Uploads + +- Files live in Neon Object Storage through `@payloadcms/storage-s3`; the `media` table holds the key and metadata, never the bytes. +- Storage branches with the database. A file uploaded on `preview` does not exist on `main`. + +## Proof + +There is no test framework. Every constraint, trigger and hand-written index is proven on the Neon `preview` branch with SQL (the `db` method in `docs/tickets/INSTRUCTIONS.md` §3), after `payload migrate` has applied it there: show that valid data passes and that the misuse it guards against fails. The `dev` branch cannot be used for this: it only ever receives dev-mode pushes, so migrations never run on it. + +## Register of departures + +Every denormalisation, banned field type used anyway, and hand-written database object, with its reason and the migration that holds it. + +| Object | Kind | Reason | Migration | +| --- | --- | --- | --- | +| None yet | | | | diff --git a/.claude/skills/payload-collection/SKILL.md b/.claude/skills/payload-collection/SKILL.md new file mode 100644 index 0000000..7771a9d --- /dev/null +++ b/.claude/skills/payload-collection/SKILL.md @@ -0,0 +1,80 @@ +--- +name: payload-collection +description: Add or change a Payload collection end to end (config, generated types, migration, proof on a Neon branch) following .claude/rules/database.md. Use when adding a collection, adding, renaming or removing a field, or writing a hand-made constraint or trigger. +--- + +# Payload Collection + +Changes one collection in `src/collections/`, following `.claude/rules/database.md`. Start from the nearest existing collection (`TourDates.ts` for content, `Media.ts` for uploads) for layout, but the rules win wherever an existing file differs from them: the first collections were written for a spike, before the rules. + +Every Neon command needs the Tandem profile: `export NEON_PROFILE=tandem`. The `--profile` flag alone is not enough for project-scoped commands. + +## 0. Read first + +- `.claude/rules/database.md`, all of it. +- The Payload docs for each field type you plan to use, through context7 (`/websites/payloadcms`). Field options change between minor versions. +- `pnpm dev` pushes the schema to whatever `DATABASE_URL` in `.env.local` points at, and that must be the Neon `dev` branch. Check without printing a value: `grep -c '^NEON_BRANCH="\?dev"\?$' .env.local` must print `1`. If it prints `0`, run `neon checkout dev`, which rewrites the Neon variables in `.env.local`. +- The admin logins for `dev` and `preview` are not in the repo. `PROMPT.md` (not committed) says where they are; if it doesn't, ask the user. Never reset a branch or a password to get in. + +## 1. Design + +For each piece of data, decide before writing config: + +1. Is it derivable? Then it is not a field. +2. Is it translatable text? Then `localized: true`. Dates, URLs, names of places and IDs are not. +3. Does it repeat? Then an `array` field, never delimited text. +4. Does it point at another document? Then one `relationship` or `upload` with a single `relationTo` and no `hasMany`. +5. Is it one of a fixed set? Then `select`. + +If the answer needs `json`, `richText`, `blocks`, `point`, a polymorphic `relationTo`, or `hasMany` on a relationship, upload, text or number field, stop and ask. A yes goes in the register in `database.md`. + +## 2. Config + +1. Write or edit `src/collections/.ts`: export a `CollectionConfig` with a plural kebab-case `slug`, `admin.useAsTitle`, explicit `access`, and the fields with `required`, `unique` and `index` set where they hold. +2. A new collection is added to `collections` in `src/payload.config.ts`. An upload collection that stores files is also added to the `s3Storage` plugin's `collections`. +3. Run `pnpm exec payload generate:types`. Run `pnpm exec payload generate:importmap` if the admin gained a custom component. + +## 3. Try it on `dev` + +1. `pnpm dev --port <4000 + issue number>`. Dev mode pushes the schema to the `dev` branch. + - A change that removes or renames a field makes the push stop and ask `Accept warnings and push schema to database?` in the terminal. A background server then hangs on its first request. For such a change, read the server output for the prompt, tell the user what would be dropped, and run the server in the foreground to answer it only once they agree. +2. In `/admin`, create, edit and delete a document. Read the dev server output for errors. +3. Stop the server by port. + +## 4. Migration + +1. `pnpm exec payload migrate:create `. +2. Read the generated SQL in `src/migrations/`. It must contain no `jsonb` or `geometry` column and no `_rels`, `_texts` or `_numbers` table for our collections, and each relationship must be a `_id` column with a foreign key. +3. A rename shows up as drop and add, which loses data. Write the `ALTER TABLE … RENAME` by hand in that migration instead and say so in the PR. + +## 5. Hand-written objects + +Only when a rule must hold for direct SQL too. + +1. With no config change pending, `pnpm exec payload migrate:create --force-accept-warning` writes a blank migration. Put the SQL in `up` and its reverse in `down`, using `db.execute(sql\`…\`)`. +2. Functions set `search_path` explicitly and are not `SECURITY DEFINER` unless they must be. +3. Add the object to the register in `database.md`. + +## 6. Apply to `preview` and prove + +1. Pull the `preview` branch's variables to a file outside the working tree: `neon env pull --branch preview --file .git/ticket//artefacts/preview.env`. Never print it. +2. Load that file into a subshell and check the target before migrating. Payload's CLI reads `.env.local` by itself, so if the file fails to load, the command silently runs against `dev`: + + ```bash + (set -a; . .git/ticket//artefacts/preview.env; set +a + echo "$NEON_BRANCH" # must print: preview + pnpm exec payload migrate:status + pnpm exec payload migrate) + ``` +3. Prove with SQL through `neon psql preview -- -Atc ""`: the table and columns exist, valid data passes, and each constraint rejects what it guards against. Keep the output for the PR. +4. After the PR's deploy preview is ready, create a document in the preview's admin and load the page that shows it. + +## 7. Production + +Never run a migration against `main`. List the step in the PR's notes for the user: `payload migrate` against the `main` branch, and any environment variable the change needs. + +## 8. Using the content + +- Server components read with `getPayload({ config })` and `payload.find`, passing the visitor's locale and `fallbackLocale: 'en'`. +- Types come from `src/payload-types.ts`. Never write a type by hand for collection data. +- With `cacheComponents` on, a read is either inside `"use cache"` with a `cacheTag`, or inside `` after `await connection()`. Invoke `vercel:next-cache-components` first. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9961f2b..840c753 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,3 +17,5 @@ jobs: - run: pnpm lint - run: pnpm typecheck - run: pnpm build + env: + SHEET_CSV_URL: ${{ vars.SHEET_CSV_URL }} diff --git a/.gitignore b/.gitignore index 2c94c88..a0cb4ff 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,7 @@ next-env.d.ts # netlify .netlify +.neon + +# session handover log +PROMPT.md diff --git a/README.md b/README.md index 8031323..3df4b87 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ Create a `.env.local` file in the root directory: ```bash # Google Sheets Configuration -NEXT_PUBLIC_CSV_URL=https://docs.google.com/spreadsheets/d/[SHEET_ID]/export?format=csv +SHEET_CSV_URL=https://docs.google.com/spreadsheets/d/[SHEET_ID]/export?format=csv # Site Configuration NEXT_PUBLIC_SITE_URL=https://clarksbowlingclub.com diff --git a/docs/tickets/INSTRUCTIONS.md b/docs/tickets/INSTRUCTIONS.md index eaac24a..15ada84 100644 --- a/docs/tickets/INSTRUCTIONS.md +++ b/docs/tickets/INSTRUCTIONS.md @@ -53,7 +53,7 @@ State lives in `.git/ticket/`, outside the working tree: per ticket, `env` (the | `cli` | A command's result | Run it | The command, its output and exit code | | `code` | A structural rule ("no request to X", "no hard-coded Y") | `grep` or reading | The command and its output | | `deploy` | Anything that depends on Netlify: headers, caching, redirects, functions, environment variables, images, the adapter | The PR's deploy preview, `https://deploy-preview---clarksbowlingclub.netlify.app`, once `gh pr checks` shows it ready | The URL, the command and its output | -| `db` | Payload and Postgres, once they exist | SQL on the local database or a Neon preview branch, never production | The SQL and its output | +| `db` | Payload and Postgres | SQL on the Neon `dev` or `preview` branch (`neon psql -- -Atc ""`), never `main` | The SQL and its output | | `mail` | The contact form | A local SMTP catcher in place of the real mailbox (§4) | The captured message's headers and body | Rules: @@ -73,7 +73,7 @@ One checkout, one ticket in flight at a time. | Package manager | pnpm. Never npm or yarn | | Dev server | `pnpm dev --port <4000 + issue number>`, e.g. ticket 27 uses 4027. Run it in the background and stop it when you're done | | The user's own server | Port 3000 belongs to the user. Never use it, never stop it | -| Env file | `.env.local` in the repo root. Read variable names only | +| Env file | `.env.local` in the repo root. Read variable names only. Once Payload lands (#33), its `DATABASE_URL` must point at the Neon `dev` branch, because `pnpm dev` will push the Payload schema to it | | Content | The published Google Sheet, read as CSV by `src/utils/fetchSheet.ts`, until Payload replaces it | | Artefacts | Screenshots, logs and scratch scripts go in `.git/ticket//artefacts/`, never in the working tree | @@ -109,6 +109,7 @@ Invoke the skill before writing code that needs it. | `netlify.toml`, redirects, headers, environment variables | `netlify-skills:netlify-config`, `netlify-skills:netlify-frameworks` | | Netlify functions, caching, image CDN | `netlify-skills:netlify-functions`, `netlify-skills:netlify-caching`, `netlify-skills:netlify-image-cdn` | | Neon Postgres and object storage | `neon:neon-postgres`, `neon:neon-object-storage` | +| A Payload collection, field or migration | `payload-collection` (rules in `.claude/rules/database.md`) | | Zod schemas | `zod4` | | A stacked branch that needs rebasing | `gh-stack` | | New or reshaped UI | `frontend-design:frontend-design` | @@ -127,15 +128,15 @@ The Netlify, Neon and GitHub tools are installed and signed in. Use them to find | Deploy previews | One per PR, at `https://deploy-preview---clarksbowlingclub.netlify.app`. `gh pr checks ` shows when it is ready | | Build | `@netlify/plugin-nextjs`; settings are in the Netlify UI until `netlify.toml` lands (#26) | | Free plan limits | 100 GB bandwidth, 300 build minutes and 125,000 function calls a month. Each push to a PR costs a build, so push as few times as you can | -| Environment variables | `EMAIL_HOST`, `EMAIL_PORT`, `EMAIL_SECURE`, `EMAIL_USER`, `EMAIL_PASSWORD` (secret), `NEXT_PUBLIC_CSV_URL` | -| Database | None yet. Payload on Neon Postgres with Neon Object Storage is planned (#32, #33); Frankfurt region, free plan | +| Environment variables | All contexts: `EMAIL_HOST`, `EMAIL_PORT`, `EMAIL_SECURE`, `EMAIL_USER`, `EMAIL_PASSWORD` (secret), `SHEET_CSV_URL` (server-only; it replaced `NEXT_PUBLIC_CSV_URL` in #27). Deploy previews only, until the migration: `DATABASE_URL`, `PAYLOAD_SECRET`, `S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY` (secrets), `S3_ENDPOINT`, `S3_REGION`, `S3_BUCKET`. Netlify reserves the `AWS_*` names, so Neon's storage credentials are stored as `S3_*` | +| Database | Neon project `cbc` (`damp-truth-56586096`), Frankfurt, free plan, in the Tandem Neon account: run Neon commands with `NEON_PROFILE=tandem`. Branches: `main` (production, empty until the migration), `preview` (shared by every deploy preview), `dev` (local). Bucket `media` on each branch. Spiked in #32; migration in #33 | -Reads are always fine: deploy logs (`netlify api getDeploy`, `listSiteDeploys`), variable names, DNS lookups. Anything that changes a hosted service needs the user's approval first; agents ask the `/tickets` driver, and the driver asks the user. +Reads are always fine: deploy logs (`netlify api getDeploy`, `listSiteDeploys`), variable names, DNS lookups. Anything that changes a hosted service needs the user's approval first; agents ask the `/tickets` driver, and the driver asks the user. The one standing exception is the Neon `dev` and `preview` branches: a ticket may push schema to `dev`, run `payload migrate` on `preview` and create test content on either. Resetting or deleting a branch still needs approval, and `main` is never written. ## 8. The codebase in brief -- Next.js 16 App Router, React 19, TypeScript 6, Tailwind 4 (theme in `src/app/globals.css`, no config file), ESLint 10. -- Each route is `src/app//page.tsx` (metadata) plus `_components/Client.tsx`. Shared UI is in `src/components/`, hooks and helpers in `src/utils/`. +- Next.js 16 App Router, React 19, TypeScript 6, Tailwind 4 (theme in `src/app/(frontend)/globals.css`, no config file), ESLint 10. +- Each route is `src/app/(frontend)//page.tsx` (metadata and server data from `src/lib/data/`) plus `_components/Client.tsx`. `robots.ts`, `sitemap.ts` and `favicon.ico` stay at `src/app/`. Shared UI is in `src/components/`, hooks and helpers in `src/utils/`. - The site is bilingual. `useLanguage()` from `src/context/LanguageContext.tsx` gives `isFrench`; every visible string has both languages. - Accessibility was audited to WCAG 2.1 AA: keep live regions, focus management, reduced-motion paths and labels working when you change a component. - Derive values during render rather than copying them into state with an effect; the lint rules enforce it. `useIsMounted` and `usePrefersReducedMotion` in `src/utils/` cover the common cases. diff --git a/next.config.ts b/next.config.ts index e9ffa30..584cbfc 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,7 +1,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { - /* config options here */ + cacheComponents: true, }; export default nextConfig; diff --git a/src/app/[...slug]/route.ts b/src/app/(frontend)/[...slug]/route.ts similarity index 85% rename from src/app/[...slug]/route.ts rename to src/app/(frontend)/[...slug]/route.ts index d57a34f..6d21ee9 100644 --- a/src/app/[...slug]/route.ts +++ b/src/app/(frontend)/[...slug]/route.ts @@ -1,8 +1,11 @@ import { NextRequest } from "next/server"; -import fetchSheet from "@/utils/fetchSheet"; -import parsePageCsv from "@/utils/parsePageCsv"; -import parseCsv from "@/utils/parseCsv"; -import { IFrameProps, LyricsProps, TourDateType } from "@/utils/types"; +import { + getAboutPage, + getLyrics, + getMusicItems, + getTourDates, + getTourPage, +} from "@/lib/data/content"; export async function GET( request: NextRequest, @@ -50,12 +53,11 @@ async function generatePageMarkdown(page: string): Promise { case "about": try { - const aboutData = await fetchSheet(0); - const aboutContent = parsePageCsv(aboutData); - if (aboutContent[1]) { - sections.push(`# ${aboutContent[1].title}`); + const { english: aboutEnglish } = await getAboutPage(); + if (aboutEnglish) { + sections.push(`# ${aboutEnglish.title}`); sections.push(""); - sections.push(aboutContent[1].content); + sections.push(aboutEnglish.content); } } catch { return null; @@ -66,11 +68,7 @@ async function generatePageMarkdown(page: string): Promise { sections.push("# Music"); sections.push(""); try { - const musicData = await fetchSheet(1713768433); - const musicItems = parseCsv( - musicData, - (row) => !!row.title && !!row.type - ); + const musicItems = await getMusicItems(); const categories = [ ...new Set( @@ -103,18 +101,13 @@ async function generatePageMarkdown(page: string): Promise { sections.push("# Tour"); sections.push(""); try { - const tourPageData = await fetchSheet(127405583); - const tourPageContent = parsePageCsv(tourPageData); - if (tourPageContent[1]?.content) { - sections.push(tourPageContent[1].content); + const { english: tourEnglish } = await getTourPage(); + if (tourEnglish?.content) { + sections.push(tourEnglish.content); sections.push(""); } - const tourData = await fetchSheet(572869052); - const tourItems = parseCsv( - tourData, - (row) => !!row.eventDate - ); + const tourItems = await getTourDates(); const now = new Date(); const futureGigs = tourItems.filter((gig) => { @@ -163,11 +156,7 @@ async function generatePageMarkdown(page: string): Promise { sections.push("# Lyrics"); sections.push(""); try { - const lyricsData = await fetchSheet(145198726); - const lyricsItems = parseCsv( - lyricsData, - (row) => !!row.title && !!row.lyrics - ); + const lyricsItems = await getLyrics(); const albums = [ ...new Set(lyricsItems.map((item) => item.album).filter(Boolean)), diff --git a/src/app/_components/HomeClient.tsx b/src/app/(frontend)/_components/HomeClient.tsx similarity index 100% rename from src/app/_components/HomeClient.tsx rename to src/app/(frontend)/_components/HomeClient.tsx diff --git a/src/app/_components/SpinningLogo.tsx b/src/app/(frontend)/_components/SpinningLogo.tsx similarity index 100% rename from src/app/_components/SpinningLogo.tsx rename to src/app/(frontend)/_components/SpinningLogo.tsx diff --git a/src/app/_components/StaticLogo.tsx b/src/app/(frontend)/_components/StaticLogo.tsx similarity index 100% rename from src/app/_components/StaticLogo.tsx rename to src/app/(frontend)/_components/StaticLogo.tsx diff --git a/src/app/about/_components/AboutClient.tsx b/src/app/(frontend)/about/_components/AboutClient.tsx similarity index 60% rename from src/app/about/_components/AboutClient.tsx rename to src/app/(frontend)/about/_components/AboutClient.tsx index e56a68e..a896ac6 100644 --- a/src/app/about/_components/AboutClient.tsx +++ b/src/app/(frontend)/about/_components/AboutClient.tsx @@ -1,11 +1,9 @@ "use client"; -import { useEffect, useState } from "react"; +import { useEffect } from "react"; import { useLanguage } from "@/context/LanguageContext"; -import { Page } from "@/utils/types"; import Carousel from "@/components/ui/Carousel"; -import parsePageCsv from "@/utils/parsePageCsv"; -import fetchSheet from "@/utils/fetchSheet"; +import { BilingualPage } from "@/lib/data/content"; const carouselImages = [ "/images/carousel/argentic.jpg", @@ -19,29 +17,9 @@ const carouselAlts = [ "Band leaving the warehouse after rehearsal and shoot", "Still of the band in Yes Day music video shoot", ]; -const sheetTabGid = 0; - -export default function AboutClient() { +export default function AboutClient({ french, english }: BilingualPage) { const { isFrench } = useLanguage(); - const [englishContent, setEnglishContent] = useState(null); - const [frenchContent, setFrenchContent] = useState(null); - - useEffect(() => { - const fetchContent = async () => { - try { - const csvData = await fetchSheet(sheetTabGid); - const parsedContent = parsePageCsv(csvData); - setEnglishContent(parsedContent[1]); - setFrenchContent(parsedContent[0]); - } catch (error) { - console.error("Error fetching or parsing page content:", error); - } - }; - - fetchContent(); - }, []); - - const pageContent = isFrench ? frenchContent : englishContent; + const pageContent = isFrench ? french : english; useEffect(() => { document.title = `${isFrench ? "Bio" : "About"} | Clark's Bowling Club`; diff --git a/src/app/about/page.tsx b/src/app/(frontend)/about/page.tsx similarity index 50% rename from src/app/about/page.tsx rename to src/app/(frontend)/about/page.tsx index e31ebd8..da1f4b5 100644 --- a/src/app/about/page.tsx +++ b/src/app/(frontend)/about/page.tsx @@ -1,10 +1,11 @@ import type { Metadata } from "next"; +import { getAboutPage } from "@/lib/data/content"; import AboutClient from "./_components/AboutClient"; export const metadata: Metadata = { title: "About", }; -export default function AboutPage() { - return ; +export default async function AboutPage() { + return ; } diff --git a/src/app/api/send-emails/route.ts b/src/app/(frontend)/api/send-emails/route.ts similarity index 100% rename from src/app/api/send-emails/route.ts rename to src/app/(frontend)/api/send-emails/route.ts diff --git a/src/app/apple-icon.png b/src/app/(frontend)/apple-icon.png similarity index 100% rename from src/app/apple-icon.png rename to src/app/(frontend)/apple-icon.png diff --git a/src/app/contact/_components/Checkbox.tsx b/src/app/(frontend)/contact/_components/Checkbox.tsx similarity index 100% rename from src/app/contact/_components/Checkbox.tsx rename to src/app/(frontend)/contact/_components/Checkbox.tsx diff --git a/src/app/contact/_components/ContactClient.tsx b/src/app/(frontend)/contact/_components/ContactClient.tsx similarity index 94% rename from src/app/contact/_components/ContactClient.tsx rename to src/app/(frontend)/contact/_components/ContactClient.tsx index 53d610b..85573d2 100644 --- a/src/app/contact/_components/ContactClient.tsx +++ b/src/app/(frontend)/contact/_components/ContactClient.tsx @@ -1,6 +1,6 @@ "use client"; -import ContactForm from "@/app/contact/_components/ContactForm"; +import ContactForm from "./ContactForm"; import { useLanguage } from "@/context/LanguageContext"; import { Page } from "@/utils/types"; import { useEffect } from "react"; diff --git a/src/app/contact/_components/ContactForm.tsx b/src/app/(frontend)/contact/_components/ContactForm.tsx similarity index 99% rename from src/app/contact/_components/ContactForm.tsx rename to src/app/(frontend)/contact/_components/ContactForm.tsx index 70de0ca..bbb757a 100644 --- a/src/app/contact/_components/ContactForm.tsx +++ b/src/app/(frontend)/contact/_components/ContactForm.tsx @@ -9,7 +9,7 @@ import Checkbox from "./Checkbox"; import { useLanguage } from "@/context/LanguageContext"; import contact_form from "@/data/contact_form.json"; -import Button from "../../../components/ui/Button"; +import Button from "@/components/ui/Button"; export default function ContactForm({ legend }: { legend: string }) { const contactForm = contact_form.reduce<{ [key: string]: string }>( diff --git a/src/app/contact/_components/TextInput.tsx b/src/app/(frontend)/contact/_components/TextInput.tsx similarity index 100% rename from src/app/contact/_components/TextInput.tsx rename to src/app/(frontend)/contact/_components/TextInput.tsx diff --git a/src/app/contact/page.tsx b/src/app/(frontend)/contact/page.tsx similarity index 100% rename from src/app/contact/page.tsx rename to src/app/(frontend)/contact/page.tsx diff --git a/src/app/globals.css b/src/app/(frontend)/globals.css similarity index 100% rename from src/app/globals.css rename to src/app/(frontend)/globals.css diff --git a/src/app/icon.svg b/src/app/(frontend)/icon.svg similarity index 100% rename from src/app/icon.svg rename to src/app/(frontend)/icon.svg diff --git a/src/app/layout.tsx b/src/app/(frontend)/layout.tsx similarity index 85% rename from src/app/layout.tsx rename to src/app/(frontend)/layout.tsx index 43c6cdf..1dd2e20 100644 --- a/src/app/layout.tsx +++ b/src/app/(frontend)/layout.tsx @@ -1,4 +1,5 @@ import type { Metadata } from "next"; +import { cacheLife } from "next/cache"; import "./globals.css"; import Header from "@/components/layout/Header"; import { LanguageProvider } from "@/context/LanguageContext"; @@ -23,13 +24,13 @@ const jost = Jost({ }); const blanchCaps = localFont({ - src: "../fonts/Blanch-Caps.woff2", + src: "../../fonts/Blanch-Caps.woff2", variable: "--next-font-blanch", display: "swap", }); const goudyStd = localFont({ - src: "../fonts/GoudyStd-Heavyface.woff2", + src: "../../fonts/GoudyStd-Heavyface.woff2", variable: "--next-font-goudy", display: "swap", }); @@ -43,7 +44,13 @@ export const metadata: Metadata = { "Clark’s Bowling Club is a 6-piece funk/pop band based in Lyon, France. Inspired by the likes of Jungle and Deluxe, their music brings a modern twist to disco-funk, hip-hop, and jazz genres, breathing new life into the vibrant music scene.", }; -export default function RootLayout({ +async function currentYear() { + "use cache"; + cacheLife("days"); + return new Date().getFullYear(); +} + +export default async function RootLayout({ children, }: Readonly<{ children: React.ReactNode; @@ -66,7 +73,7 @@ export default function RootLayout({ {children} -