remove .ttf hack

remove-ttf-hack
Rich Harris 10 months ago
parent 83628c901d
commit d02389a599

File diff suppressed because it is too large Load Diff

@ -28,8 +28,8 @@
},
"devDependencies": {
"@resvg/resvg-js": "^2.4.1",
"@sveltejs/adapter-vercel": "^3.0.3",
"@sveltejs/kit": "^1.26.0",
"@sveltejs/adapter-vercel": "^5.1.0",
"@sveltejs/kit": "^2.4.1",
"@sveltejs/site-kit": "6.0.0-next.50",
"@sveltejs/vite-plugin-svelte": "^2.4.6",
"@types/cookie": "^0.5.2",

@ -5,12 +5,15 @@ import satori from 'satori';
import { html as toReactNode } from 'satori-html';
import Card from './Card.svelte';
import OverpassRegular from './Overpass-Regular.ttf';
import { read } from '$app/server';
const height = 630;
const width = 1200;
export const prerender = true;
const font_data = await read(OverpassRegular).arrayBuffer();
export async function GET({ params }) {
const post = await get_processed_blog_post(await get_blog_data(), params.slug);
@ -24,7 +27,7 @@ export async function GET({ params }) {
fonts: [
{
name: 'Overpass',
data: Buffer.from(OverpassRegular),
data: font_data,
style: 'normal',
weight: 400
}

@ -1,9 +1,9 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { browserslistToTargets } from 'lightningcss';
import { readFile } from 'node:fs/promises';
import browserslist from 'browserslist';
const plugins = [raw(['.ttf']), sveltekit()];
/** @type {any[]} */
const plugins = [sveltekit()];
// Only enable sharp if we're not in a webcontainer env
if (!process.versions.webcontainer) {
@ -20,22 +20,6 @@ if (!process.versions.webcontainer) {
);
}
/**
* @param {string[]} ext
* @returns {import("vite").Plugin}
*/
function raw(ext) {
return {
name: 'vite-plugin-raw',
async transform(_, id) {
if (ext.some((e) => id.endsWith(e))) {
const buffer = await readFile(id);
return { code: `export default ${JSON.stringify(buffer)}`, map: null };
}
}
};
}
/** @type {import('vite').UserConfig} */
const config = {
logLevel: 'info',

Loading…
Cancel
Save