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:
@@ -20,7 +20,7 @@
|
||||
"id": "barrel",
|
||||
"label": "Barrel",
|
||||
"labelPlural": "Barrels",
|
||||
"symbol": "dlbbl",
|
||||
"symbol": "bbl",
|
||||
"group": "dickloads",
|
||||
"toBase": 19
|
||||
},
|
||||
@@ -28,18 +28,10 @@
|
||||
"id": "hogshead",
|
||||
"label": "Hogshead",
|
||||
"labelPlural": "Hogsheads",
|
||||
"symbol": "dlhhd",
|
||||
"symbol": "hhd",
|
||||
"group": "dickloads",
|
||||
"toBase": 38
|
||||
},
|
||||
{
|
||||
"id": "assload",
|
||||
"label": "Assload",
|
||||
"labelPlural": "Assloads",
|
||||
"symbol": "assl",
|
||||
"group": "dickloads",
|
||||
"toBase": 2
|
||||
},
|
||||
{
|
||||
"id": "short-ton",
|
||||
"label": "Short ton",
|
||||
@@ -48,14 +40,6 @@
|
||||
"group": "dickloads",
|
||||
"toBase": 76
|
||||
},
|
||||
{
|
||||
"id": "long-ton",
|
||||
"label": "Long ton",
|
||||
"labelPlural": "Long tons",
|
||||
"symbol": "long tn",
|
||||
"group": "dickloads",
|
||||
"toBase": 85.1199999999
|
||||
},
|
||||
{
|
||||
"id": "fuckton",
|
||||
"label": "Fuck ton",
|
||||
@@ -64,6 +48,14 @@
|
||||
"group": "dickloads",
|
||||
"toBase": 152
|
||||
},
|
||||
{
|
||||
"id": "long-ton",
|
||||
"label": "Long ton",
|
||||
"labelPlural": "Long tons",
|
||||
"symbol": "long tn",
|
||||
"group": "dickloads",
|
||||
"toBase": 85.1199999999
|
||||
},
|
||||
{
|
||||
"id": "metric-fuckton",
|
||||
"label": "Metric fuckton",
|
||||
@@ -72,6 +64,14 @@
|
||||
"group": "dickloads",
|
||||
"toBase": 170.2399999998
|
||||
},
|
||||
{
|
||||
"id": "assload",
|
||||
"label": "Assload",
|
||||
"labelPlural": "Assloads",
|
||||
"symbol": "assl",
|
||||
"group": "dickloads",
|
||||
"toBase": 2
|
||||
},
|
||||
{
|
||||
"id": "shitload",
|
||||
"label": "Shitload",
|
||||
|
||||
32
src/lib/brand.ts
Normal file
32
src/lib/brand.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
6
src/routes/+layout.server.ts
Normal file
6
src/routes/+layout.server.ts
Normal 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) };
|
||||
};
|
||||
@@ -2,8 +2,10 @@
|
||||
import '@picocss/pico/css/pico.min.css';
|
||||
import '../app.css';
|
||||
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';
|
||||
const CYCLE: Theme[] = ['light', 'dark', 'dan'];
|
||||
@@ -33,7 +35,7 @@
|
||||
<header>
|
||||
<nav class="container">
|
||||
<ul>
|
||||
<li><strong>Humor Units</strong></li>
|
||||
<li><strong>{brand.name}</strong></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="/">Converter</a></li>
|
||||
@@ -57,5 +59,5 @@
|
||||
</main>
|
||||
|
||||
<footer class="container">
|
||||
<small>Humor Units — invented conversions for invented purposes</small>
|
||||
<small>{brand.footer}</small>
|
||||
</footer>
|
||||
|
||||
Reference in New Issue
Block a user