@bbki.ng/site 5.5.27 → 5.5.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 5.5.28
4
+
5
+ ### Patch Changes
6
+
7
+ - a1c157f: icon font preloading
8
+
3
9
  ## 5.5.27
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "5.5.27",
3
+ "version": "5.5.28",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -22,6 +22,7 @@ export const FontRules: Array<FontRule> = [
22
22
  src: '/fonts/yao-icons.woff2',
23
23
  format: 'woff2',
24
24
  hideGlyphOnLoading: true,
25
+ preload: true,
25
26
  },
26
27
  },
27
28
  ];
@@ -5,6 +5,7 @@ export interface FontConfig {
5
5
  fontWeight?: string;
6
6
  fontStyle?: string;
7
7
  hideGlyphOnLoading?: boolean;
8
+ preload?: boolean;
8
9
  }
9
10
 
10
11
  export interface FontRule {
@@ -13,6 +13,17 @@ export const loadFont = (config: FontConfig) => {
13
13
  `
14
14
  : '';
15
15
 
16
+ const existingLink = document.querySelector(`link[rel="preload"][href="${config.src}"]`);
17
+ if (config.preload && !existingLink) {
18
+ const link = document.createElement('link');
19
+ link.rel = 'preload';
20
+ link.as = 'font';
21
+ link.href = config.src;
22
+ link.type = `font/${config.format}`;
23
+ link.crossOrigin = 'anonymous';
24
+ document.head.appendChild(link);
25
+ }
26
+
16
27
  const style = document.createElement('style');
17
28
  style.id = styleId;
18
29
  style.textContent = `