Something went wrong. Try again.
Mirror of https://github.com/kualta/site — web infrastructure
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071import contacts from "@/data/contacts.json";import imageSizes from "@/data/image-sizes.json";
export const SITE_URL = "https://kualta.dev";export const SITE_NAME = "kualta";export const TAGLINE = "a servant of many";export const TWITTER = "@kualts";export const DEFAULT_OG_IMAGE = "/opengraph-image.png";
/** * the accounts that make the Person entity resolvable to the same human, * read from the contacts list so a new account is claimed everywhere at once */export const SAME_AS = contacts.map((contact) => contact.link).filter((link) => link.startsWith("https://"));
/** * Every tab and every result reads "<page> - kualta", so a bare "posts" or * "music" is never adrift from whose posts and whose music it is. */export function pageTitle(title?: string): string { if (!title || title === SITE_NAME) return SITE_NAME; return title.endsWith(SITE_NAME) ? title : `${title} - ${SITE_NAME}`;}
/** Use the supplied description without adding copy. */export function pageDescription(description?: string): string { return description ?? TAGLINE;}
const sizes = imageSizes as Record<string, { width: number; height: number }>;
const MIME: Record<string, string> = { png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg", gif: "image/gif", webp: "image/webp", avif: "image/avif", svg: "image/svg+xml",};
export interface OgImage { url: string; width?: number; height?: number; type?: string;}
/** * Share cards were claiming 1200x630 for images that are nothing of the sort, * which is how a 2048x1152 preview reached scrapers as a lie about its own * aspect ratio. The real numbers come from the manifest built off `public/`. *//** what the scrapers can actually decode; avif and svg come back blank */const SHAREABLE = new Set(["png", "jpg", "jpeg", "gif", "webp"]);
export function ogImage(source: string | undefined, site: URL | undefined): OgImage { const candidate = source?.trim() || DEFAULT_OG_IMAGE; const usable = SHAREABLE.has(candidate.split(".").pop()?.toLowerCase() ?? ""); const relative = usable ? candidate : DEFAULT_OG_IMAGE; const size = sizes[relative]; const extension = relative.split(".").pop()?.toLowerCase() ?? "";
return { url: new URL(relative, site ?? SITE_URL).toString(), width: size?.width, height: size?.height, type: MIME[extension], };}