Skip to content
Public-Vinyl-RadioPublic

About

Public website for Public Vinyl Radio

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

Public Vinyl Radio

The official website for Public Vinyl Radio, a Seattle-based music collective showcasing DJ sets, radio shows, and live performances.

Tech Stack

  • Framework: Gatsby 5 (React-based static site generator)
  • Language: TypeScript
  • Styling: Tailwind CSS v4 (utility classes, configured in src/styles/global.css)
  • Content: MDX (Markdown + React components)
  • Hosting: Netlify
  • Audio Storage: Cloudflare R2

Features

  • Audio Streaming: Custom-built audio players for streaming MP3s from Cloudflare R2
  • Show Pages: Dynamic pages for each radio show/episode with metadata and tracklists
  • Merch Store: Product catalog and pages (/shop, /shop/<id>) with a cart and Stripe checkout; order management via CLI scripts
  • Public Events: Event listing (/events) with post-event recaps — recap audio, photo collages, and tracklists
  • Private Events & RSVP: Access-code event pages (/e/<code>) with RSVP, an organizer admin view (/e/<code>/admin), and RSVP cancellation
  • Collaborators: Host/collaborator profile pages (/collaborators/<slug>)
  • Newsletter Signup: Email capture via a serverless API route
  • SEO Optimized: Automatic meta tags, Open Graph images, and structured data
  • Image Optimization: Automatic image processing via Gatsby Image
  • Embedded Media: Support for YouTube, Spotify, and Apple Music embeds
  • Responsive Design: Mobile-first, dark-themed UI (light mode scaffolded but not yet enabled)

Getting Started

Prerequisites

  • Node.js 18-20
  • npm or yarn

Installation

# Clone the repository
git clone <repository-url>
cd pvr-site

# Install dependencies
npm install

Development

# Start development server
npm run develop

# Site will be available at http://localhost:8000
# GraphQL playground at http://localhost:8000/___graphql

Building

# Build for production
npm run build

# Serve production build locally
npm run serve

# Type checking
npm run typecheck

# Clean cache (useful when things break)
gatsby clean

Project Structure

pvr-site/
├── src/
│   ├── components/          # React components
│   │   ├── r2-audio-player.tsx
│   │   ├── r2-playlist-player.tsx
│   │   ├── spotify.tsx
│   │   ├── youtube.tsx
│   │   └── ...
│   ├── content/
│   │   └── shows/          # MDX files for shows
│   ├── templates/          # Page templates
│   ├── pages/              # Static pages
│   └── types/              # TypeScript types
├── gatsby-config.ts        # Site configuration
├── gatsby-node.ts          # Build-time Node API
└── package.json

Adding New Shows

Shows are created as MDX files in src/content/shows/:

---
title: 'Show Title'
description: 'Show description'
episode: 1
date: '2025-12-14'
tags: ['Genre1', 'Genre2']
slug: 'show-slug'
host: ['DJ Name']
template: show
isActive: true
coverImage: './cover.jpg'
---

import R2AudioPlayer from '../../components/r2-audio-player';

<R2AudioPlayer
  url="https://pub-xxx.r2.dev/audio.mp3"
  title="Show Title"
/>

## About This Show

Your content here...

Frontmatter Options

  • title - Show title (required)
  • description - Show description (required)
  • episode - Episode number
  • date - Show date in YYYY-MM-DD format
  • tags - Array of genre tags
  • slug - URL slug (required)
  • host - Array of DJ/host names
  • template - Must be show
  • isActive - Set to false to hide from listings
  • coverImage - Path to cover image (shown if no YouTube video)
  • youtubeId - YouTube video ID for embedding

Events

Events are data-driven (no MDX), backed by two JSON files that the CLI scripts read and write:

  • src/data/public-events.data.json — public events, listed on /events and rendered at /events/<slug>.
  • src/data/events.data.json — private listening sessions, reachable only via an access code at /e/<code> (organizer view at /e/<code>/admin).

Lifecycle: create an event (event:new), then after it happens enrich the public event's recap (event:recap / event:photos / event:audio / event:tracklist).

Creating events

Use the interactive event builder for public events and private listening sessions. It validates the shared event slug, writes the appropriate data file, and creates static/images/events/<slug>/ for event assets.

npm run event:new
npm run event:new -- --dry-run  # review the generated event without writing files

Private sessions are unlisted. The builder generates a five-character link at /e/<code>; share that link directly with guests rather than linking it from the public site.

Post-event recaps

After a public event happens, enrich its /events/<slug> page with a recap. Each script is interactive, lets you pick from past events, and supports --dry-run. They write into src/data/public-events.data.json; the audio/photo scripts also upload to Cloudflare R2 (see the Stripe/1Password and R2 notes for credential setup).

npm run audio:prep       # prep a raw set recording: join splits, trim silence -> WAV/MP3
npm run event:recap      # upload the set audio + pull a tracklist; writes audioUrl + tracklist
npm run event:photos     # resize a folder of photos to .webp, upload, add a photo collage
npm run event:audio      # swap only the recap audio for an event
npm run event:tracklist  # re-sync only the tracklist (after fixing it upstream)

Add :dry for a no-write preview, e.g. npm run event:recap:dry. See CLAUDE.md for the full event lifecycle, data files, and the groovenet/R2 details.

Shop

src/data/products.ts is the single source of truth for the shop. The storefront renders from it, checkout resolves its price lookup keys, and the sync script pushes it to Stripe — you should rarely touch the Stripe dashboard directly.

Adding / updating a product

  1. Scaffold the entry — an interactive prompt that appends a formatted product to src/data/products.ts and creates its image folder:

    npm run shop:new

    It asks for the name, id, description, price, tags, image filenames, and variants (generating <id>--<variant> lookup keys). To edit an existing product instead, just change its entry in src/data/products.ts by hand.

  2. Add source images to static/images/shop/<product-id>/ as .png (or .jpg) — the folder is created for you by shop:new. High-res originals are fine; they get downscaled.

  3. Generate optimized images — creates the .webp (product cards) and -thumb.webp (cart drawer) derivatives from each source file:

    npm run shop:images            # missing/stale only
    npm run shop:images -- --force # regenerate everything
  4. Preview locally with npm run develop.

  5. Push to Stripe sandbox, then promote to live once you're happy:

    npm run shop:sync:sandbox                # write to the sandbox account
    npm run shop:sync:sandbox -- --dry-run   # preview changes, writes nothing
    npm run shop:sync:live                   # promote the same catalog to live

    The sync is idempotent — it creates products/prices that are missing, updates names/descriptions/images that drifted, and (because Stripe prices are immutable) when a price changes it creates a new Price, moves the lookup key onto it, and archives the old one. Re-running is always safe.

Removing a product

npm run shop:remove -- <product-id>            # remove entry + image folder only
npm run shop:remove:sandbox -- <product-id>    # also archive its Stripe products (sandbox)
npm run shop:remove:live -- <product-id>       # also archive in live
npm run shop:remove:all -- <product-id>        # archive in both, then remove

Deletes the entry from products.ts and its static/images/shop/<id>/ folder, and (with :sandbox/:live/:all) archives the per-variant Stripe products so they drop off Checkout. Prompts for confirmation; add --yes to skip, --keep-images to keep the folder, or --dry-run to preview. (Stripe products with prices can't be hard-deleted, so they're archived — same as "Archive" in the dashboard.) Stripe products are found by their pvr_id stamp, so archiving still works even if you already deleted the products.ts entry by hand.

Generating an order PDF

Create a PVR-branded receipt and packing slip from a Stripe Checkout Session or Payment Intent. This is read-only: it retrieves the order details but makes no Stripe changes.

# Sandbox Checkout Session (cs_test_...)
npm run order:pdf:sandbox -- cs_test_123

# Live Checkout Session, written to a chosen location
npm run order:pdf:live -- cs_live_123 --output=./orders/pvr-order.pdf

# Payment Intent IDs work too
npm run order:pdf:sandbox -- pi_123

The default output is .generated/orders/order-<id>.pdf, a gitignored local directory. The command will not replace an existing file unless --force is supplied. The template includes the PVR display and mono fonts, customer shipping details, line items, shipping, discount, tax, and total. The order header uses a short PVR reference rather than Stripe's long internal Payment Intent ID. Like the shop sync commands, the scripts obtain their corresponding Stripe key from 1Password.

Tracking fulfillment

Stripe is the source of truth for fulfillment state. When a paid Checkout Session is received, the webhook records it as paid; marking an order shipped adds its carrier, tracking number, and shipping timestamp to both the Checkout Session and its Payment Intent. This makes the status visible in Stripe's normal Payment details view.

# Show the 25 newest completed orders (use --limit=100 for more)
npm run order:list:sandbox

# Mark an order shipped using its PVR reference, Checkout Session, or Payment Intent ID
npm run order:ship:sandbox -- PVR-20260726-ABC123 --carrier=USPS --tracking=9400111899223856928499

# A shipment email is sent by default. Deliberately send another only when needed.
npm run order:ship:sandbox -- PVR-20260726-ABC123 --carrier=USPS --tracking=9400111899223856928499 --resend-email

# Backfill shipment metadata without emailing the customer again.
npm run order:ship:sandbox -- PVR-20260726-ABC123 --carrier=USPS --tracking=9400111899223856928499 --no-email

Before using this in production, create a Stripe webhook endpoint at https://publicvinylradio.com/api/stripe-webhook, listen for checkout.session.completed and checkout.session.async_payment_succeeded, and add its signing secret to Netlify as STRIPE_WEBHOOK_SECRET. The endpoint verifies Stripe's signature before writing any fulfillment metadata.

order:ship also emails the customer after recording the shipment. Configure RESEND_API_KEY, ORDER_EMAIL_FROM, and ORDER_EMAIL_REPLY_TO in both Netlify and the local environment used by the CLI (for example, as 1Password references in .env.op). The command records the Resend email ID and timestamp in Stripe and will refuse to send another shipment email unless --resend-email is provided.

Stripe credentials via 1Password

The sync scripts pull secrets from 1Password at runtime using op run --env-file=.env.op. .env.op contains only op:// references (no secrets), so it's safe to commit.

Create the two 1Password items the references point at (run these yourself so the keys never leave your machine — paste your real Stripe keys in place of the placeholders):

# Sandbox key (starts with sk_test_...)
op item create \
  --category="API Credential" \
  --vault="PVR" \
  --title="Stripe PVR Sandbox" \
  "secret key[password]=sk_test_REPLACE_ME"

# Live key (starts with sk_live_...)
op item create \
  --category="API Credential" \
  --vault="PVR" \
  --title="Stripe PVR Live" \
  "secret key[password]=sk_live_REPLACE_ME"

Then verify the references resolve:

op run --env-file=.env.op -- printenv STRIPE_SECRET_KEY_SANDBOX

If you keep the keys in a different vault or under different item names, update --vault=/--title= above and edit the matching op:// lines in .env.op. (op vault list shows your vault names.)

Notes

  • Requires the 1Password CLI (op) installed and signed in. The scripts run on Node's native TypeScript support (Node 22+), so there's no build step.

  • Local checkout — the /api/create-checkout route needs STRIPE_SECRET_KEY at runtime. Start the dev server with the sandbox key injected from 1Password:

    npm run dev   # = op run --env-file=.env.op -- npx netlify dev

    Plain npm run develop works for everything except placing an order. (In production, Netlify provides STRIPE_SECRET_KEY as the live key.)

  • Variants become separate Stripe products. A product with variants syncs as one Stripe Product per variant, named <product> — <variant> (e.g. PVR Tee — Large), so the size shows on the Checkout page. The cart and lookup keys are unchanged.

  • Product images must be publicly reachable URLs (Stripe can't host arbitrary product images for you). The sync points Stripe at the deployed site's .webp files, so run npm run shop:images first. A brand-new product's images aren't on the live site until you deploy — until then the product syncs without images (you'll see a warning) and picks them up on the next sync after deploy. To preview images before merging, sync against a public Netlify deploy-preview URL: npm run shop:sync:sandbox -- --image-base=https://deploy-preview-NN--yoursite.netlify.app. Images are only re-sent when their bytes or the base URL change (tracked via an image_hash on the Stripe product).

  • Products are matched to Stripe by metadata.pvr_id (= the product id), so the same catalog maps cleanly onto both the sandbox and live accounts.

  • The sync never archives Stripe products removed from products.ts — clean those up in the dashboard if needed.

Audio Streaming

Audio files are hosted on Cloudflare R2. To use the audio player:

  1. Upload MP3 to your R2 bucket
  2. Make sure CORS is configured for your domain
  3. Use the R2AudioPlayer component in your MDX
<R2AudioPlayer
  url="https://pub-{bucket-id}.r2.dev/path/to/file.mp3"
  title="Episode Title"
  showDownload={true}
/>

Deployment

The site is automatically deployed to Netlify when changes are pushed to the main branch.

Environment Variables

Configure these in Netlify:

  • Any API keys or secrets needed for builds

Contributing

  1. Create a new branch for your changes
  2. Make your changes
  3. Test locally with npm run develop
  4. Create a pull request

License

All rights reserved - Public Vinyl Radio

Contact

For questions or support, contact the Public Vinyl Radio team.

About

Public website for Public Vinyl Radio

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages