UNPKG

unplugin-fonts

Version:
30 lines (29 loc) 614 B
//#region src/loaders/typekit.ts function typekitLoader({ id, defer = true, injectTo = "head-prepend", fontBaseUrl = "https://use.typekit.net/" }) { const tags = []; if (typeof id !== "string") { console.warn("A Typekit id is required"); return tags; } if (defer) tags.push({ tag: "link", injectTo, attrs: { rel: "preload", as: "style", onload: "this.rel='stylesheet'", href: `${fontBaseUrl}${id}.css` } }); else tags.push({ tag: "link", injectTo, attrs: { rel: "stylesheet", href: `${fontBaseUrl}${id}.css` } }); return tags; } //#endregion export { typekitLoader };