From d774e08ad99f0a834d3a1fc4ff701e0b22fec0bc Mon Sep 17 00:00:00 2001 From: emeraldjava Date: Tue, 31 Dec 2024 16:51:45 +0000 Subject: [PATCH] Add vercel image generation. --- astro.config.ts | 16 ++++++++++++ package-lock.json | 50 +++++++++++++++++++++++++++++++++++-- package.json | 3 ++- src/utils/loadGoogleFont.ts | 22 ++++++++++------ 4 files changed, 80 insertions(+), 11 deletions(-) diff --git a/astro.config.ts b/astro.config.ts index 477fa949..b2dede75 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -53,6 +53,7 @@ export default defineConfig({ // } // } // }, + plugins: [rawFonts(['.ttf'])], optimizeDeps: { exclude: ["@resvg/resvg-js"], }, @@ -66,3 +67,18 @@ export default defineConfig({ // So we're instructing Astro to put the static build output in a folder of that name. outDir: "./dist", }); + +function rawFonts(ext) { + return { + name: 'vite-plugin-raw-fonts', + transform(_, id) { + if (ext.some(e => id.endsWith(e))) { + const buffer = fs.readFileSync(id); + return { + code: `export default ${JSON.stringify(buffer)}`, + map: null + }; + } + } + }; +} diff --git a/package-lock.json b/package-lock.json index 34104956..2c352695 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,18 @@ { "name": "emeraldjava.github.io", - "version": "2024.10.30", + "version": "2024.11.16", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "emeraldjava.github.io", - "version": "2024.10.30", + "version": "2024.11.16", "dependencies": { "@astrojs/check": "^0.9.3", "@astrojs/rss": "^4.0.7", "@giscus/react": "^3.0.0", "@resvg/resvg-js": "^2.6.2", + "@vercel/og": "^0.6.4", "astro": "^4.16.3", "fuse.js": "^7.0.0", "lodash.kebabcase": "^4.1.1", @@ -1519,6 +1520,15 @@ "node": ">= 10" } }, + "node_modules/@resvg/resvg-wasm": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@resvg/resvg-wasm/-/resvg-wasm-2.4.0.tgz", + "integrity": "sha512-C7c51Nn4yTxXFKvgh2txJFNweaVcfUPQxwEUFw4aWsCmfiBDJsTSwviIF8EcwjQ6k8bPyMWCl1vw4BdxE569Cg==", + "license": "MPL-2.0", + "engines": { + "node": ">= 10" + } + }, "node_modules/@rollup/pluginutils": { "version": "5.1.3", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.3.tgz", @@ -2218,6 +2228,42 @@ "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==" }, + "node_modules/@vercel/og": { + "version": "0.6.4", + "resolved": "https://registry.npmjs.org/@vercel/og/-/og-0.6.4.tgz", + "integrity": "sha512-+IB8fYbVHEAtLfhCXSRS61Q/OfBJTaPCXhvGvXTBIUfs9lqZMDesZ2UnvKYbnEYHSMgCzBaj5BOq66iePl8mjw==", + "license": "MPL-2.0", + "dependencies": { + "@resvg/resvg-wasm": "2.4.0", + "satori": "0.12.0", + "yoga-wasm-web": "0.3.3" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@vercel/og/node_modules/satori": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/satori/-/satori-0.12.0.tgz", + "integrity": "sha512-e0e+qQyeFwEszujN7SpWpRtZgww7Nh8lSO3bUn2spHZ5JpqEl3zJ3P14/JlWruxEwdgREs35ZnavrPrWaRVFDg==", + "license": "MPL-2.0", + "dependencies": { + "@shuding/opentype.js": "1.4.0-beta.0", + "css-background-parser": "^0.1.0", + "css-box-shadow": "1.0.0-3", + "css-gradient-parser": "^0.0.16", + "css-to-react-native": "^3.0.0", + "emoji-regex": "^10.2.1", + "escape-html": "^1.0.3", + "linebreak": "^1.1.0", + "parse-css-color": "^0.2.1", + "postcss-value-parser": "^4.2.0", + "yoga-wasm-web": "^0.3.3" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/@vitejs/plugin-react": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.3.1.tgz", diff --git a/package.json b/package.json index f71e36a8..99a9b74c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "emeraldjava.github.io", - "version": "2024.11.16", + "version": "2024.12.21", "scripts": { "dev": "astro dev", "start": "astro dev", @@ -18,6 +18,7 @@ "@astrojs/rss": "^4.0.7", "@giscus/react": "^3.0.0", "@resvg/resvg-js": "^2.6.2", + "@vercel/og": "^0.6.4", "astro": "^4.16.3", "fuse.js": "^7.0.0", "lodash.kebabcase": "^4.1.1", diff --git a/src/utils/loadGoogleFont.ts b/src/utils/loadGoogleFont.ts index cfd5c564..20ce0789 100644 --- a/src/utils/loadGoogleFont.ts +++ b/src/utils/loadGoogleFont.ts @@ -45,17 +45,23 @@ async function loadGoogleFonts( > { const fontsConfig = [ { - name: "IBM Plex Mono", - font: "IBM+Plex+Mono", + name: "Space Mono", + font: "Space+Mono", weight: 400, style: "normal", }, - { - name: "IBM Plex Mono", - font: "IBM+Plex+Mono:wght@700", - weight: 700, - style: "bold", - }, + // { + // name: "IBM Plex Mono", + // font: "IBM+Plex+Mono", + // weight: 400, + // style: "normal", + // }, + // { + // name: "IBM Plex Mono", + // font: "IBM+Plex+Mono:wght@700", + // weight: 700, + // style: "bold", + // }, ]; const fonts = await Promise.all(