inline the fonts

This commit is contained in:
Adam Burgess 2021-12-09 13:53:34 +11:00
parent e91a52f1d8
commit e9deeeb4db
2 changed files with 2 additions and 7 deletions

2
deploy
View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
rm -rf dist && nr build rm -rf dist && nr build
curl https://deploy.arm.adam.id.au/client.mjs > /tmp/client.mjs curl -q https://deploy.arm.adam.id.au/client.mjs > /tmp/client.mjs
DEPLOY_PATH=dist DEPLOY_PROJECT=homepage DEPLOY_CADDYFILE=Caddyfile node /tmp/client.mjs DEPLOY_PATH=dist DEPLOY_PROJECT=homepage DEPLOY_CADDYFILE=Caddyfile node /tmp/client.mjs

View File

@ -33,12 +33,7 @@ for (const [name, f] of Object.entries(fonts)) {
const words = typeof selector === 'string' ? Array.from(doc.querySelectorAll(selector)).map(x => x.textContent).join(' ') : selector(); const words = typeof selector === 'string' ? Array.from(doc.querySelectorAll(selector)).map(x => x.textContent).join(' ') : selector();
const subset = await subsetFont(await readFile(path), words, { targetFormat: 'woff2' }); const subset = await subsetFont(await readFile(path), words, { targetFormat: 'woff2' });
const hash = makeHash(subset); html = html.replace(`FONT_${name}_${weight}`, 'data:font/woff2;base64,' + subset.toString('base64'));
const outName = `static/${name}-${weight}.${hash}.woff2`;
html = html.replace(`FONT_${name}_${weight}`, outName);
await writeFile('dist/' + outName, subset);
} }
} }