mirror of
https://github.com/LukeHagar/sveltekit-og.git
synced 2025-12-06 20:57:46 +00:00
Vercel Setup
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
"private": false,
|
"private": false,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
"build:prod": "vite build",
|
||||||
"build": "svelte-kit sync && svelte-package",
|
"build": "svelte-kit sync && svelte-package",
|
||||||
"prepublishOnly": "echo 'Did you mean to publish `./package/`, instead of `./`?' && exit 1",
|
"prepublishOnly": "echo 'Did you mean to publish `./package/`, instead of `./`?' && exit 1",
|
||||||
"test": "playwright test",
|
"test": "playwright test",
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import type { SvelteComponent } from 'svelte';
|
|||||||
import type { SatoriOptions } from 'satori';
|
import type { SatoriOptions } from 'satori';
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const resSvgWasm = initWasm(readFileSync(join(__filename, '../vendors/resvg.wasm')));
|
const resSvgWasm = initWasm(readFileSync(join(__filename, '../vendors/resvg.wasm')));
|
||||||
const fontFile = await fetch('https://og-playground.vercel.app/inter-latin-ext-700-normal.woff');
|
const fontFile = await fetch('https://github.com/etherCorps/sveltekit-og/blob/main/static/noto-sans.ttf');
|
||||||
const fontData: ArrayBuffer = await fontFile.arrayBuffer();
|
const fontData: ArrayBuffer = await fontFile.arrayBuffer();
|
||||||
|
|
||||||
export const ImageResponse = class {
|
export const ImageResponse = class {
|
||||||
@@ -20,14 +20,17 @@ export const ImageResponse = class {
|
|||||||
const svg = await satori(toReactNode(htmlTemplate), {
|
const svg = await satori(toReactNode(htmlTemplate), {
|
||||||
width: options.width,
|
width: options.width,
|
||||||
height: options.height,
|
height: options.height,
|
||||||
|
debug: options.debug,
|
||||||
fonts: options.fonts || [
|
fonts: options.fonts || [
|
||||||
{
|
{
|
||||||
name: 'Noto Sans',
|
name: 'sans serif',
|
||||||
data: fontData,
|
data: fontData,
|
||||||
style: 'normal'
|
style: 'normal',
|
||||||
|
weight: 700
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
console.log(svg)
|
||||||
const pngData = new Resvg(svg, { fitTo: { mode: 'width', value: options.width } });
|
const pngData = new Resvg(svg, { fitTo: { mode: 'width', value: options.width } });
|
||||||
a.enqueue(await pngData.render().asPng());
|
a.enqueue(await pngData.render().asPng());
|
||||||
a.close();
|
a.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user