From bec4ea90324d98b406c38370612ed8806c0382d0 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Wed, 20 Nov 2024 15:58:04 +0800 Subject: [PATCH] Switch to Google Fonts v2 API --- scripts/helpers/font.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/helpers/font.js b/scripts/helpers/font.js index 5c46090ef..517e8e425 100644 --- a/scripts/helpers/font.js +++ b/scripts/helpers/font.js @@ -6,7 +6,7 @@ module.exports = function() { if (!config || !config.enable) return ''; - const fontStyles = ':300,300italic,400,400italic,700,700italic'; + const fontStyles = ':ital,wght@0,300;0,400;0,700;1,300;1,400;1,700'; const fontHost = config.host || 'https://fonts.googleapis.com'; // Get a font list from config @@ -18,8 +18,8 @@ module.exports = function() { }); fontFamilies = fontFamilies.map(name => name.trim().replace(/\s/g, '+') + fontStyles); - fontFamilies = [...new Set(fontFamilies)].join('%7C'); + fontFamilies = [...new Set(fontFamilies)].map(name => 'family=' + name).join('&'); // Merge extra parameters to the final processed font string - return fontFamilies ? `` : ''; + return fontFamilies ? `` : ''; };