feat: domain-based branding (humorunits.com / dickloads.com)

- src/lib/brand.ts: Brand config map, getBrand() reads hostname server-side
- src/routes/+layout.server.ts: new, passes brand to layout
- +layout.svelte: site name and footer driven by brand config
- humorunits.com footer: 'invented conversions for ridiculous people'
- dickloads.com footer: placeholder (pending Shannon's pick)
This commit is contained in:
Falkan
2026-03-18 19:27:49 -04:00
parent b1a5586c25
commit 6e38522a89
4 changed files with 61 additions and 21 deletions

View File

@@ -20,7 +20,7 @@
"id": "barrel", "id": "barrel",
"label": "Barrel", "label": "Barrel",
"labelPlural": "Barrels", "labelPlural": "Barrels",
"symbol": "dlbbl", "symbol": "bbl",
"group": "dickloads", "group": "dickloads",
"toBase": 19 "toBase": 19
}, },
@@ -28,18 +28,10 @@
"id": "hogshead", "id": "hogshead",
"label": "Hogshead", "label": "Hogshead",
"labelPlural": "Hogsheads", "labelPlural": "Hogsheads",
"symbol": "dlhhd", "symbol": "hhd",
"group": "dickloads", "group": "dickloads",
"toBase": 38 "toBase": 38
}, },
{
"id": "assload",
"label": "Assload",
"labelPlural": "Assloads",
"symbol": "assl",
"group": "dickloads",
"toBase": 2
},
{ {
"id": "short-ton", "id": "short-ton",
"label": "Short ton", "label": "Short ton",
@@ -48,14 +40,6 @@
"group": "dickloads", "group": "dickloads",
"toBase": 76 "toBase": 76
}, },
{
"id": "long-ton",
"label": "Long ton",
"labelPlural": "Long tons",
"symbol": "long tn",
"group": "dickloads",
"toBase": 85.1199999999
},
{ {
"id": "fuckton", "id": "fuckton",
"label": "Fuck ton", "label": "Fuck ton",
@@ -64,6 +48,14 @@
"group": "dickloads", "group": "dickloads",
"toBase": 152 "toBase": 152
}, },
{
"id": "long-ton",
"label": "Long ton",
"labelPlural": "Long tons",
"symbol": "long tn",
"group": "dickloads",
"toBase": 85.1199999999
},
{ {
"id": "metric-fuckton", "id": "metric-fuckton",
"label": "Metric fuckton", "label": "Metric fuckton",
@@ -72,6 +64,14 @@
"group": "dickloads", "group": "dickloads",
"toBase": 170.2399999998 "toBase": 170.2399999998
}, },
{
"id": "assload",
"label": "Assload",
"labelPlural": "Assloads",
"symbol": "assl",
"group": "dickloads",
"toBase": 2
},
{ {
"id": "shitload", "id": "shitload",
"label": "Shitload", "label": "Shitload",

32
src/lib/brand.ts Normal file
View File

@@ -0,0 +1,32 @@
/**
* Brand configuration keyed by hostname (www-stripped).
* Add new domains here — no other changes needed.
*/
export interface Brand {
/** Site name shown in nav and page titles. */
name: string;
/** Footer tagline. */
footer: string;
}
const BRANDS: Record<string, Brand> = {
'humorunits.com': {
name: 'Humor Units',
footer: 'Humor Units — invented conversions for ridiculous people.',
},
'dickloads.com': {
name: 'Dick Loads',
footer: 'Dick Loads — serious units for serious people.',
},
};
const DEFAULT_BRAND = BRANDS['humorunits.com'];
export function getBrand(requestUrl: string): Brand {
try {
const host = new URL(requestUrl).hostname.replace(/^www\./, '');
return BRANDS[host] ?? DEFAULT_BRAND;
} catch {
return DEFAULT_BRAND;
}
}

View File

@@ -0,0 +1,6 @@
import { getBrand } from '$lib/brand';
import type { LayoutServerLoad } from './$types';
export const load: LayoutServerLoad = ({ request }) => {
return { brand: getBrand(request.url) };
};

View File

@@ -2,8 +2,10 @@
import '@picocss/pico/css/pico.min.css'; import '@picocss/pico/css/pico.min.css';
import '../app.css'; import '../app.css';
import { browser } from '$app/environment'; import { browser } from '$app/environment';
import type { Brand } from '$lib/brand';
let { children } = $props(); let { children, data }: { children: any; data: { brand: Brand } } = $props();
let brand = $derived(data.brand);
type Theme = 'light' | 'dark' | 'dan'; type Theme = 'light' | 'dark' | 'dan';
const CYCLE: Theme[] = ['light', 'dark', 'dan']; const CYCLE: Theme[] = ['light', 'dark', 'dan'];
@@ -33,7 +35,7 @@
<header> <header>
<nav class="container"> <nav class="container">
<ul> <ul>
<li><strong>Humor Units</strong></li> <li><strong>{brand.name}</strong></li>
</ul> </ul>
<ul> <ul>
<li><a href="/">Converter</a></li> <li><a href="/">Converter</a></li>
@@ -57,5 +59,5 @@
</main> </main>
<footer class="container"> <footer class="container">
<small>Humor Units — invented conversions for invented purposes</small> <small>{brand.footer}</small>
</footer> </footer>