fix: tidying broke generation

This commit is contained in:
Mythie
2023-08-31 12:08:53 +10:00
parent 14fd0eb906
commit 7722e63e1b
2 changed files with 17 additions and 12 deletions

View File

@ -11,13 +11,6 @@ export const size = {
export const contentType = 'image/png'; export const contentType = 'image/png';
const OG_IMAGE_ASSETS = [
'./../../../../assets/inter-bold.ttf',
'./../../../../assets/inter-regular.ttf',
'./../../../../assets/background-blog-og.png',
'./../../../../../public/logo.png',
];
type BlogPostOpenGraphImageProps = { type BlogPostOpenGraphImageProps = {
params: { post: string }; params: { post: string };
}; };
@ -29,11 +22,22 @@ export default async function BlogPostOpenGraphImage({ params }: BlogPostOpenGra
return null; return null;
} }
const [interBold, interRegular, backgroundImage, logoImage] = await Promise.all( // The long urls are needed for a compiler optimisation on the Next.js side, lifting this up
OG_IMAGE_ASSETS.map(async (asset) => // to a constant will break og image generation.
fetch(new URL(asset, import.meta.url)).then(async (res) => res.arrayBuffer()), const [interBold, interRegular, backgroundImage, logoImage] = await Promise.all([
fetch(new URL('./../../../../assets/inter-bold.ttf', import.meta.url)).then(async (res) =>
res.arrayBuffer(),
), ),
); fetch(new URL('./../../../../assets/inter-regular.ttf', import.meta.url)).then(async (res) =>
res.arrayBuffer(),
),
fetch(new URL('./../../../../assets/background-blog-og.png', import.meta.url)).then(
async (res) => res.arrayBuffer(),
),
fetch(new URL('./../../../../../public/logo.png', import.meta.url)).then(async (res) =>
res.arrayBuffer(),
),
]);
return new ImageResponse( return new ImageResponse(
( (

3
package-lock.json generated
View File

@ -16319,6 +16319,7 @@
} }
}, },
"packages/ee": { "packages/ee": {
"name": "@documenso/ee",
"version": "1.0.0", "version": "1.0.0",
"license": "COMMERCIAL", "license": "COMMERCIAL",
"dependencies": { "dependencies": {
@ -16362,7 +16363,7 @@
"packages/lib": { "packages/lib": {
"name": "@documenso/lib", "name": "@documenso/lib",
"version": "1.0.0", "version": "1.0.0",
"license": "SEE LICENSE IN LICENSE", "license": "MIT",
"dependencies": { "dependencies": {
"@documenso/email": "*", "@documenso/email": "*",
"@documenso/prisma": "*", "@documenso/prisma": "*",