fix: resolve preload href warnings
This commit is contained in:
parent
7a26fc3a9a
commit
aa77e9bfb9
3 changed files with 10 additions and 7 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
const path = require("path").posix;
|
||||||
const slugify = require("slugify");
|
const slugify = require("slugify");
|
||||||
|
|
||||||
const slugifyString = (string) => {
|
const slugifyString = (string) => {
|
||||||
|
@ -6,6 +7,9 @@ const slugifyString = (string) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getFontUrl = (src) => path.join("/assets/fonts", src);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
getFontUrl,
|
||||||
slugifyString,
|
slugifyString,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
const fonts = require("./fonts");
|
const { getFontUrl } = require("../../config/utils");
|
||||||
|
const fonts = require("../../config/design-tokens/fonts.json");
|
||||||
|
|
||||||
const preloads = [
|
const preloads = [
|
||||||
{
|
{
|
||||||
as: "font",
|
as: "font",
|
||||||
href: fonts.display.weights.extraBold.url,
|
href: getFontUrl(fonts.display.weights.ExtraBold.path),
|
||||||
crossorigin: true,
|
crossorigin: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
as: "font",
|
as: "font",
|
||||||
href: fonts.display.weights.bold.url,
|
href: getFontUrl(fonts.display.weights.Bold.path),
|
||||||
crossorigin: true,
|
crossorigin: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
as: "font",
|
as: "font",
|
||||||
href: fonts.body.weights.regular.url,
|
href: getFontUrl(fonts.body.weights.Regular.path),
|
||||||
crossorigin: true,
|
crossorigin: true,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
const path = require("path").posix;
|
const { getFontUrl } = require("../../config/utils");
|
||||||
const fonts = require("../../config/design-tokens/fonts.json");
|
const fonts = require("../../config/design-tokens/fonts.json");
|
||||||
|
|
||||||
const getFontUrl = (src) => path.join("/assets/fonts", src);
|
|
||||||
|
|
||||||
const fontsToCss = (fonts) => {
|
const fontsToCss = (fonts) => {
|
||||||
return Object.entries(fonts).reduce((css, [, fontProperties]) => {
|
return Object.entries(fonts).reduce((css, [, fontProperties]) => {
|
||||||
const family = fontProperties.family;
|
const family = fontProperties.family;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue