You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by bz...@apache.org on 2022/07/06 08:08:17 UTC

[apisix-website] branch master updated: feat: optimize font loading speed (#1191)

This is an automated email from the ASF dual-hosted git repository.

bzp2010 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-website.git


The following commit(s) were added to refs/heads/master by this push:
     new bf6018c43a6 feat: optimize font loading speed (#1191)
bf6018c43a6 is described below

commit bf6018c43a60184edcf0c736acde939b51a6fe60
Author: Young <is...@outlook.com>
AuthorDate: Wed Jul 6 16:08:11 2022 +0800

    feat: optimize font loading speed (#1191)
---
 website/config/ssrTemplate.js   |  5 +++++
 website/src/css/customTheme.css | 16 ++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/website/config/ssrTemplate.js b/website/config/ssrTemplate.js
index 1cba3d83886..01f7b3ba26b 100644
--- a/website/config/ssrTemplate.js
+++ b/website/config/ssrTemplate.js
@@ -13,6 +13,11 @@ module.exports = {
       <% it.metaAttributes.forEach((metaAttribute) => { %>
         <%~ metaAttribute %>
       <% }); %>
+      <link rel="preload" href="https://static.apiseven.com/202202/MaisonNeue-Medium.otf" as="font" type="font/otf" crossorigin>
+      <link rel="preload" href="https://static.apiseven.com/202202/MaisonNeue-Bold.otf" as="font" type="font/otf" crossorigin>
+      <link rel="preload" href="https://static.apiseven.com/202202/MaisonNeue-Light.otf" as="font" type="font/otf" crossorigin>
+      <link rel="preload" href="https://static.apiseven.com/202202/MaisonNeue-Demi.otf"  as="font" type="font/otf" crossorigin>
+      <link rel="preload" href="https://static.apiseven.com/202202/MaisonNeue-ExtraBold.otf" as="font" type="font/otf" crossorigin>
       <% it.scripts.forEach((script) => { %>
         <link rel="preload" href="<%= process.env.preview ? '' : 'https://apisix-website-static.apiseven.com' %><%= it.baseUrl %><%= script %>" as="script">
       <% }); %>
diff --git a/website/src/css/customTheme.css b/website/src/css/customTheme.css
index 3c81af56b43..c24abdaaa80 100644
--- a/website/src/css/customTheme.css
+++ b/website/src/css/customTheme.css
@@ -59,7 +59,7 @@ html[data-theme="dark"] {
     local("MaisonNeue-Medium"),
     url("https://static.apiseven.com/202202/MaisonNeue-Medium.otf")
     format("opentype");
-  font-display: swap;
+  font-display: optional;
 }
 
 @font-face {
@@ -68,7 +68,7 @@ html[data-theme="dark"] {
     local("MaisonNeue-Bold"),
     url("https://static.apiseven.com/202202/MaisonNeue-Bold.otf")
     format("opentype");
-  font-display: swap;
+  font-display: optional;
 }
 
 @font-face {
@@ -77,7 +77,7 @@ html[data-theme="dark"] {
     local("MaisonNeue-Light"),
     url("https://static.apiseven.com/202202/MaisonNeue-Light.otf")
     format("opentype");
-  font-display: swap;
+  font-display: optional;
 }
 
 @font-face {
@@ -86,7 +86,7 @@ html[data-theme="dark"] {
     local("MaisonNeue-Demi"),
     url("https://static.apiseven.com/202202/MaisonNeue-Demi.otf")
     format("opentype");
-  font-display: swap;
+  font-display: optional;
 }
 
 @font-face {
@@ -95,7 +95,7 @@ html[data-theme="dark"] {
     local("MaisonNeue-ExtraBold"),
     url("https://static.apiseven.com/202202/MaisonNeue-ExtraBold.otf")
     format("opentype");
-  font-display: swap;
+  font-display: optional;
 }
 
 ::-webkit-scrollbar {
@@ -118,7 +118,11 @@ body,
 h1,
 h2,
 h3 {
-  font-family: MaisonNeue-Medium, sans-serif;
+  font-family: MaisonNeue-Medium, apple-system, system-ui, sans-serif;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+  text-rendering: optimizelegibility;
+  text-size-adjust: 100%;
 }
 
 div.inner {