Page MenuHomeSealhub

get-fonts.ts
No OneTemporary

get-fonts.ts

import { readFile } from "fs/promises";
import { constructURL, download } from "google-fonts-helper";
import { target_locreq } from "./target-locreq.js";
export const FONTS_CONFIG_PATH = "src/fonts.json";
export async function getFonts(_: Record<string, string | boolean> = {}) {
const fonts_config_path = target_locreq.resolve(FONTS_CONFIG_PATH);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const fonts_config = JSON.parse(await readFile(fonts_config_path, "utf8"));
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
const fonts_url = constructURL(fonts_config.googleFonts);
if (!fonts_url) {
throw new Error("Invalid font config");
}
const downloader = download(fonts_url, {
base64: false,
overwriting: false,
outputDir: target_locreq.resolve("public/dist/fonts"),
stylePath: "fonts.css",
fontsDir: "./",
fontsPath: "/dist/fonts",
});
await downloader.execute();
console.log("Downloaded new fonts pack");
}

File Metadata

Mime Type
text/x-java
Expires
Tue, Dec 24, 14:03 (11 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
557258
Default Alt Text
get-fonts.ts (1021 B)

Event Timeline