Deploy production / deploy (push) Successful in 1m30s
- tab registry in #lib/price-trackers (add a tab = route + entry + icon) - groceries -> /trackers/prices/groceries (owner-only), CS prices -> /trackers/prices/cs (public) - old /trackers/groceries/* and /projects/cs-prices/* redirect (301 GET, 308 POST) with query - nav: one prices entry replaces groceries and skins; cyan price-tag icon
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
export type SiteEnvironment = 'DEV' | 'STAGING' | null;
|
|
|
|
export function siteEnvironment(isDev: boolean, origin?: string): SiteEnvironment {
|
|
if (isDev) return 'DEV';
|
|
try {
|
|
return new URL(origin ?? '').hostname === 'staging.stanrunge.dev' ? 'STAGING' : null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function formatTitle(title: string, environment: SiteEnvironment = null): string {
|
|
return `${environment ? `(${environment}) ` : ''}${title} | Stan Runge`;
|
|
}
|
|
|
|
export function getTitle(path: string, environment: SiteEnvironment = null): string {
|
|
const titles: Record<string, string> = {
|
|
'/': 'Home',
|
|
'/projects': 'Projects',
|
|
'/trackers': 'Trackers',
|
|
'/trackers/books': 'Reading',
|
|
'/trackers/spotting': 'Spotting',
|
|
'/trackers/cars': 'Cars',
|
|
'/trackers/planes': 'Planes',
|
|
'/trackers/trains': 'Trains',
|
|
'/trackers/wildlife': 'Wildlife',
|
|
'/trackers/pc': 'PC setup',
|
|
'/blog': 'Blog',
|
|
'/lists': 'Lists',
|
|
'/login': 'Sign in',
|
|
'/register': 'Register',
|
|
'/account': 'Account',
|
|
'/projects/game-tracker/pokemon': 'Catchemall',
|
|
'/projects/game-tracker/pokemon/locations': 'Pokémon locations',
|
|
'/projects/animaldex': 'Animaldex',
|
|
'/projects/animaldex/register': 'Log a sighting',
|
|
'/projects/animaldex/admin': 'Animaldex admin',
|
|
'/projects/derby': 'Derby Lens',
|
|
'/trackers/prices': 'Prices',
|
|
'/trackers/prices/cs': 'CS Prices',
|
|
'/trackers/prices/groceries': 'Groceries',
|
|
'/trackers/games': 'Game Tracker',
|
|
'/projects/language-learner': 'Language Learner',
|
|
'/projects/spotify-beatmap-finder': 'osu! map finder',
|
|
'/projects/progress': 'Progress',
|
|
'/stats/world/politics': 'World Opinions',
|
|
'/trackers/money': 'Money'
|
|
};
|
|
const cleaned = path.replace(/\/$/, '') || '/';
|
|
const title =
|
|
titles[cleaned] ?? cleaned.split('/').filter(Boolean).at(-1)?.replace(/-/g, ' ') ?? 'Home';
|
|
return formatTitle(title, environment);
|
|
}
|