AFFiNE/scripts/download-blocksuite-fonts.mjs
野声 f393f89a3f
fix(server): blank screen on mobile (#8460)
Co-authored-by: forehalo <forehalo@gmail.com>
2024-10-16 13:12:40 +08:00

29 lines
692 B
JavaScript

import { writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { AffineCanvasTextFonts } from '@blocksuite/blocks';
const fontPath = join(
fileURLToPath(import.meta.url),
'..',
'..',
'packages',
'frontend',
'core',
'public',
'fonts'
);
await Promise.all(
AffineCanvasTextFonts.map(async ({ url }) => {
const buffer = await fetch(url).then(res =>
res.arrayBuffer().then(res => Buffer.from(res))
);
const filename = url.split('/').pop();
const distPath = join(fontPath, filename);
await writeFile(distPath, buffer);
console.info(`Downloaded ${distPath} successfully`);
})
);