Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | 12x 12x 1x 2x 66x 66x 1828563x 66x 12x 11x 66x 66x 3x 11x 1x | import type { Hono } from 'hono';
import type { AppEnv } from '../app.ts';
import { FONTS } from './fonts.generated.ts';
import { ICONS } from './icons.generated.ts';
/** The web app manifest's path; the pages link it so a home-screen shortcut gets the icon and the name. */
export const MANIFEST_PATH = '/manifest.webmanifest';
/** The `<link>` tags every page carries: the tab icon, the iOS home-screen icon, and the manifest. */
export const ICON_LINKS = {
favicon: ICONS.favicon.path,
appleTouch: ICONS.appleTouch.path,
manifest: MANIFEST_PATH,
} as const;
/** The web app manifest of the Leaderboard pages. */
export function webManifest() {
return {
name: 'Be-Music Leaderboard',
short_name: 'Leaderboard',
start_url: '/',
scope: '/',
display: 'browser',
background_color: '#0a0e18',
theme_color: '#0a0e18',
icons: [ICONS.manifest192, ICONS.manifest512].map((icon) => ({
src: icon.path,
sizes: `${icon.size}x${icon.size}`,
type: icon.contentType,
})),
};
}
function decode(base64: string): Uint8Array<ArrayBuffer> {
const text = atob(base64);
const bytes = new Uint8Array(text.length);
for (let i = 0; i < text.length; i++) bytes[i] = text.charCodeAt(i);
return bytes;
}
/** The share card's Latin typeface: the client script loads it before drawing a card. */
export const CARD_FONT = { family: FONTS.interTight.family, url: FONTS.interTight.path } as const;
/** Serves the icons and the fonts (content-hashed, cached for good) and the manifest. */
export function mountIcons(app: Hono<AppEnv>): void {
for (const icon of [...Object.values(ICONS), ...Object.values(FONTS)]) {
const bytes = decode(icon.base64);
app.get(icon.path, (c) =>
c.body(bytes, 200, { 'content-type': icon.contentType, 'cache-control': 'public, max-age=31536000, immutable' }),
);
}
app.get(MANIFEST_PATH, (c) =>
c.body(JSON.stringify(webManifest()), 200, {
'content-type': 'application/manifest+json',
'cache-control': 'public, max-age=3600',
}),
);
}
|