diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..bb4fa4c --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,58 @@ +# AGENTS.md + +## Critical Rules + +- **Svelte 5 runes only**: Use `$state`, `$derived`, `$props` - never legacy `$:` or `export let` +- **Context limitation**: `setContext` must be called during component initialization, NOT in `$effect` +- **No custom CSS**: Use TailwindCSS utility classes exclusively +- **TypeScript strict**: All code must be typed, no `any` without justification +- **Package manager**: Use `npm`, not pnpm + +## Non-Obvious Architecture + +### External Data Source + +Brewery data comes from a separate repository: https://github.com/openbrewerydb/openbrewerydb + +- Data contributions go to the dataset repo, NOT this repo +- This repo is the web interface/API wrapper + +### SEO Pattern + +- Use `SEO` component from `src/lib/components/SEO.svelte` +- Use `SEOProvider` for nested SEO configuration +- Context merges parent/child configs via `mergeSEO()` in `src/lib/seo.ts` +- **Important**: `setContext` in SEOProvider must be called synchronously during init, not in effects + +### State Management + +- Stores in `src/lib/stores/` use Svelte 5 runes (e.g., `breweries.svelte.ts`) +- Prefer runes over stores for local component state +- Only use stores when state needs to be shared across unrelated components + +### Type Organization + +- `src/lib/types.ts`: Core types (Brewery, BreweryType, Metadata) +- `src/lib/types/`: Additional type modules (e.g., `metrics.ts`) + +### Data Build Scripts + +Require `GITHUB_TOKEN` environment variable: + +- `npm run data:build` - builds all data +- `npm run authors:build` - GitHub authors +- `npm run changelogs:build` - changelog data +- `npm run contributors:build` - contributor data + +## Environment Variables + +```env +SENTRY_AUTH_TOKEN=your_sentry_token # Optional, for error tracking +GITHUB_TOKEN=your_github_token # Required for data build scripts +``` + +## Deployment + +- Uses Cloudflare Pages/Workers via `@sveltejs/adapter-cloudflare` +- Config: `wrangler.toml`, `svelte.config.js` +- Auto-deploys on push to main via GitHub integration diff --git a/src/lib/components/BreweriesTable.svelte b/src/lib/components/BreweriesTable.svelte index 1f36114..40c81d7 100644 --- a/src/lib/components/BreweriesTable.svelte +++ b/src/lib/components/BreweriesTable.svelte @@ -67,17 +67,17 @@ > {brewery.address_1 ?? ''} - {brewery.city} - {brewery.postal_code} {brewery.country}{subtitle}

{description}

diff --git a/src/lib/components/MetricCard.svelte b/src/lib/components/MetricCard.svelte index bf3fd40..2f2703d 100644 --- a/src/lib/components/MetricCard.svelte +++ b/src/lib/components/MetricCard.svelte @@ -24,10 +24,10 @@ {label} {#if subtitle} -
{subtitle}
+
{subtitle}
{/if} {#if breakdown && breakdown.length > 0} -
+
{#each breakdown as item (item.label)}
{item.label}: {formatNumber(item.value)} diff --git a/src/lib/components/MetricsSummary.svelte b/src/lib/components/MetricsSummary.svelte index 9402c26..d47d32d 100644 --- a/src/lib/components/MetricsSummary.svelte +++ b/src/lib/components/MetricsSummary.svelte @@ -25,14 +25,14 @@ Statistics

Here's how many developers and breweries we serve every week.

{#if !metrics}
-

Metrics unavailable

+

Metrics unavailable

{:else if metrics && period}
@@ -65,11 +65,11 @@ {formatBandwidth(period.bandwidth_tb)}
Bandwidth
-
7 days
+
7 days
-
+
{#if isDataStale(metrics.last_updated)}

⚠️ Metrics data may be outdated diff --git a/src/lib/components/MobileNav.svelte b/src/lib/components/MobileNav.svelte index e339f27..70818f1 100644 --- a/src/lib/components/MobileNav.svelte +++ b/src/lib/components/MobileNav.svelte @@ -1,5 +1,5 @@ +

+ + +
t * (2 - t) }} + class="fixed inset-y-0 right-0 z-50 w-full max-w-sm bg-white shadow-2xl md:hidden flex flex-col" > +
-
-
- -
-
-
+ Menu + +
+ + +
+
Home Breweries -
+
+ {:else} + + Previous + + {/if} + + + Page {page} of {totalPages} + + + {#if context === 'search' && onPageChange} + + {:else} + = totalPages ? '#' : getPageUrl(page + 1)} + > + Next + + {/if} +
+ + + +
+{/if} diff --git a/src/lib/components/SearchPagination.svelte b/src/lib/components/SearchPagination.svelte deleted file mode 100644 index 51c49e2..0000000 --- a/src/lib/components/SearchPagination.svelte +++ /dev/null @@ -1,62 +0,0 @@ - - -{#if totalPages > 1} -
- - -
- {#each Array(Math.min(totalPages, maxPagesToShow)) as _item, i (i)} - {@const pageNum = i + 1} - - {/each} -
- - -
-{/if} diff --git a/src/lib/components/SectionContent.svelte b/src/lib/components/SectionContent.svelte index a8017f8..60ac093 100644 --- a/src/lib/components/SectionContent.svelte +++ b/src/lib/components/SectionContent.svelte @@ -14,7 +14,7 @@ {title}

{content}

diff --git a/src/lib/data/state-country-mapping.json b/src/lib/data/state-country-mapping.json new file mode 100644 index 0000000..db2de9f --- /dev/null +++ b/src/lib/data/state-country-mapping.json @@ -0,0 +1,190 @@ +{ + "ACT": "Australia", + "Alabama": "United States", + "Bayern": "Germany", + "Aveiro": "Portugal", + "Arizona": "United States", + "Baden-Württemberg": "Germany", + "Argyll": "Scotland", + "Alaska": "United States", + "Bavaria": "Germany", + "Arkansas": "United States", + "British Columbia": "Canada", + "Bouche du Rhône": "France", + "Bolzano": "Italy", + "Bute": "Scotland", + "Beja": "Portugal", + "Brandenburg": "Germany", + "Blekinge": "Sweden", + "Bremen": "Germany", + "Berlin": "Germany", + "Busan": "South Korea", + "California": "United States", + "Central Ostrobothnia": "Finland", + "Colorado": "United States", + "Clare": "Ireland", + "Chungcheongbukdo": "South Korea", + "Carlow": "Ireland", + "Connecticut": "United States", + "Coimbra": "Portugal", + "Chungcheongnamdo": "South Korea", + "Central Finland": "Finland", + "Drenthe": "Netherlands", + "Daejeon": "South Korea", + "Dnipropetrovsk Oblast": "Ukraine", + "Delaware": "United States", + "Cork": "Ireland", + "Dublin": "Ireland", + "East Dunbartonshire": "Scotland", + "Donegal": "Ireland", + "District of Columbia": "United States", + "Deagu": "South Korea", + "Faro": "Portugal", + "Galway": "Ireland", + "Gangwondo": "South Korea", + "Eastern Cape": "South Africa", + "Florida": "United States", + "Gauteng": "South Africa", + "Friesland": "Netherlands", + "East Sussex": "England", + "Free State": "South Africa", + "Flevoland": "Netherlands", + "Gwangju": "South Korea", + "Hawaii": "United States", + "Groningen": "Netherlands", + "Hamburg": "Germany", + "Gyeonggido": "South Korea", + "Gelderland": "Netherlands", + "Georgia": "United States", + "Halland": "Sweden", + "Gyeongsangnamdo": "South Korea", + "Gyeongsangbukdo": "South Korea", + "Illinois": "United States", + "Jeollabukdo": "South Korea", + "Iowa": "United States", + "Indiana": "United States", + "Incheon": "South Korea", + "Jejudo": "South Korea", + "Jeollanamdo": "South Korea", + "Hessen": "Germany", + "Hesse": "Germany", + "Idaho": "United States", + "Kildare": "Ireland", + "KwaZulu-Natal": "South Africa", + "Kansas": "United States", + "K�rnten": "Austria", + "Kymenlaakso": "Finland", + "Kentucky": "United States", + "Kanta-Häme": "Finland", + "Kilkenny": "Ireland", + "Kainuu": "Finland", + "Kerry": "Ireland", + "Louisiana": "United States", + "Longford": "Ireland", + "Lapland": "Finland", + "Laois": "Ireland", + "Limerick": "Ireland", + "Lisboa": "Portugal", + "Limburg": "Netherlands", + "Louth": "Ireland", + "Limpopo": "South Africa", + "Leiria": "Portugal", + "Maine": "United States", + "Massachusetts": "United States", + "Middle": "Isle of Man", + "Lower Saxony": "Germany", + "Michigan": "United States", + "Maryland": "United States", + "Mecklenburg-Vorpommern": "Germany", + "Mayo": "Ireland", + "MIssouri": "United States", + "Meath": "Ireland", + "Mpumalanga": "South Africa", + "Nebraska": "United States", + "Montana": "United States", + "Missouri": "United States", + "Mississippi": "United States", + "NSW": "Australia", + "NT": "Australia", + "SA": "Australia", + "WA": "Australia", + "Monaghan": "Ireland", + "Minnesota": "United States", + "Nevada": "United States", + "Noord-Holland": "Netherlands", + "Noord-Brabant": "Netherlands", + "Nordrhein-Westfalen": "Germany", + "New York": "United States", + "New Mexico": "United States", + "New Jersey": "United States", + "North Carolina": "United States", + "New Hampshire": "United States", + "Niedersachsen": "Germany", + "Nieder�sterreich": "Austria", + "Ohio": "United States", + "Oklahoma": "United States", + "Offaly": "Ireland", + "North Rhine-Westphalia": "Germany", + "Oberösterreich": "Austria", + "North West": "South Africa", + "North Dakota": "United States", + "Ontario": "Canada", + "North Savo": "Finland", + "Northern Ostrobothnia": "Finland", + "Päijät-Häme": "Finland", + "Oregon": "United States", + "Ostrobothnia": "Finland", + "Portalegre": "Portugal", + "Pirkanmaa": "Finland", + "Overijssel": "Netherlands", + "Pennsylvania": "United States", + "Porto": "Portugal", + "QLD": "Australia", + "Osaka": "Japan", + "Saarland": "Germany", + "Rhode Island": "United States", + "Roscommon": "Ireland", + "Rheinland-Pfalz": "Germany", + "Satakunta": "Finland", + "Rhineland-Palatinate": "Germany", + "Salzburg": "Austria", + "Sachsen-Anhalt": "Germany", + "Sachsen": "Germany", + "South Ostrobothnia": "Finland", + "South Carolina": "United States", + "Schleswig-Holstein": "Germany", + "Seoul": "South Korea", + "South Dakota": "United States", + "Singapore": "Singapore", + "South Karelia": "Finland", + "Steiermark": "Austria", + "Sligo": "Ireland", + "South Savo": "Finland", + "Uusimaa": "Finland", + "Tipperary": "Ireland", + "Varsinais-Suomi": "Finland", + "Tennessee": "United States", + "Utrecht": "Netherlands", + "Utah": "United States", + "Thüringen": "Germany", + "TAS": "Australia", + "Texas": "United States", + "VIC": "Australia", + "West Virginia": "United States", + "Western Cape": "South Africa", + "Westmeath": "Ireland", + "Waterford": "Ireland", + "Virginia": "United States", + "Washington": "United States", + "West Sussex": "England", + "Vermont": "United States", + "West Dunbartonshire": "Scotland", + "Wicklow": "Ireland", + "Zuid-Holland": "Netherlands", + "Wyoming": "United States", + "Åland": "Finland", + "dolnośląskie": "Poland", + "Wisconsin": "United States", + "Zeeland": "Netherlands", + "Wexford": "Ireland" +} diff --git a/src/routes/b/[id]/+page.svelte b/src/routes/b/[id]/+page.svelte index 605efb9..1ff209b 100644 --- a/src/routes/b/[id]/+page.svelte +++ b/src/routes/b/[id]/+page.svelte @@ -99,10 +99,7 @@
{#if brewery.address_1}
- + {brewery.address_1}{brewery.address_2 ? `, ${brewery.address_2}` @@ -111,10 +108,7 @@
{/if}
- +
- + {#if brewery.phone}
- + {brewery.phone}
{/if} @@ -168,7 +156,14 @@