data endpoint for entity 90008 (aka. a website)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

opengraph image

dawn b161e832 f272f518

+44 -1
+12
eunomia/src/lib/constellation.ts
··· 4 4 import { join } from 'node:path'; 5 5 import { env } from '$env/dynamic/private'; 6 6 import type { Canvas } from 'skia-canvas'; 7 + import sharp from 'sharp'; 7 8 8 9 const DATA_DIR = join(env.WEBSITE_DATA_DIR ?? '', 'constellation'); 9 10 const GRAPH_FILE = join(DATA_DIR, 'graph_processed.json'); 10 11 const OUTPUT_FILE = join(DATA_DIR, 'background.svg'); 11 12 const DUST_FILE = join(DATA_DIR, 'background_dust.webp'); 13 + const OG_IMAGE_FILE = join(DATA_DIR, 'og_image.png'); 12 14 const STARS_FILE = join(DATA_DIR, 'stars.json'); 13 15 const GRAPH_URL = 'https://eightyeightthirty.one/graph.json'; 14 16 ··· 699 701 angleX 700 702 } 701 703 })); 704 + 705 + console.log('generating OG image...'); 706 + (async () => { 707 + const resized_svg = await sharp(OUTPUT_FILE).resize({ height: 256 }).toBuffer(); 708 + sharp(DUST_FILE) 709 + .resize({ height: 256 }) 710 + .composite([{ input: resized_svg }]) 711 + .png() 712 + .toFile(OG_IMAGE_FILE); 713 + })(); 702 714 703 715 console.log(`rendered constellation in ${Date.now() - start}ms`); 704 716 } catch (error) {
+4 -1
eunomia/src/routes/(site)/+layout.svelte
··· 63 63 <title>{title}</title> 64 64 <meta property="og:site_name" content="gaze.systems" /> 65 65 <meta property="og:url" content="https://gaze.systems/" /> 66 - <meta property="og:image" content="https://gaze.systems/icons/gaze_website.webp" /> 66 + <meta property="og:image" content="https://gaze.systems/_api/background/og-image.png" /> 67 + <meta property="og:image:type" content="image/png" /> 68 + <meta property="og:image:width" content="455" /> 69 + <meta property="og:image:height" content="256" /> 67 70 </svelte:head> 68 71 69 72 <img
+28
eunomia/src/routes/_api/background/og-image.png/+server.ts
··· 1 + import { readFile, stat } from 'node:fs/promises'; 2 + import { join } from 'node:path'; 3 + import { env } from '$env/dynamic/private'; 4 + import { initConstellation } from '$lib/constellation'; 5 + 6 + export const GET = async () => { 7 + const filePath = join(env.WEBSITE_DATA_DIR, 'constellation', 'og_image.png'); 8 + 9 + try { 10 + await stat(filePath); 11 + } catch (e) { 12 + await initConstellation(); 13 + } 14 + 15 + try { 16 + const file = await readFile(filePath); 17 + 18 + return new Response(file, { 19 + headers: { 20 + 'Content-Type': 'image/png', 21 + 'Cache-Control': 'public, max-age=3600' 22 + } 23 + }); 24 + } catch (err) { 25 + console.error(`error serving og image: ${err}`); 26 + return new Response('not found', { status: 404 }); 27 + } 28 + };