mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: non-blocking font importing
This commit is contained in:
1 parent
f28e8c8acb
commit
1b59ca9bb5
1 file changed
+9
-3
@@ -6,8 +6,12 @@ import satori from 'satori';
|
|||||||
const FONT_NAME = 'Roboto';
|
const FONT_NAME = 'Roboto';
|
||||||
const FONT_FILES = ['Roboto', 'Roboto-Bold', 'Roboto-Black'];
|
const FONT_FILES = ['Roboto', 'Roboto-Bold', 'Roboto-Black'];
|
||||||
|
|
||||||
|
let robotoFlex: Buffer;
|
||||||
|
let robotoFlexBold: Buffer;
|
||||||
|
let robotoFlexBlack: Buffer;
|
||||||
|
|
||||||
console.log('Importing fonts...');
|
console.log('Importing fonts...');
|
||||||
const [robotoFlex, robotoFlexBold, robotoFlexBlack] = await Promise.all(
|
await Promise.all(
|
||||||
FONT_FILES.map(
|
FONT_FILES.map(
|
||||||
(file) =>
|
(file) =>
|
||||||
new Promise<Buffer>((resolve, reject) => {
|
new Promise<Buffer>((resolve, reject) => {
|
||||||
@@ -17,8 +21,10 @@ const [robotoFlex, robotoFlexBold, robotoFlexBlack] = await Promise.all(
|
|||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
);
|
).then((data) => {
|
||||||
console.log('Fonts imported');
|
[robotoFlex, robotoFlexBold, robotoFlexBlack] = data;
|
||||||
|
console.log('Fonts imported');
|
||||||
|
});
|
||||||
|
|
||||||
export default async function render(element: ReactNode) {
|
export default async function render(element: ReactNode) {
|
||||||
const svg = await satori(element, {
|
const svg = await satori(element, {
|
||||||
|
|||||||
Reference in new issue
Block a user