From 88118e0fb7af179d657b166328d33bd0a16b461d Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 16 Dec 2022 10:33:32 +0800 Subject: [PATCH] fix font-custom --- components/CommonHead.js | 6 ++++++ pages/_app.js | 13 ++----------- tailwind.config.js | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/components/CommonHead.js b/components/CommonHead.js index de4c7d25..5938dc6d 100644 --- a/components/CommonHead.js +++ b/components/CommonHead.js @@ -43,6 +43,12 @@ const CommonHead = ({ meta, children }) => { + + { BLOG.CUSTOM_FONT + ? BLOG.CUSTOM_FONT_URL?.map(fontUrl => + ) + : } + {JSON.parse(BLOG.ANALYTICS_BUSUANZI_ENABLE) && } {meta?.type === 'Post' && ( <> diff --git a/pages/_app.js b/pages/_app.js index 79506c43..200a6b43 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -49,9 +49,9 @@ const MyApp = ({ Component, pageProps }) => { {JSON.parse(BLOG.FIREWORKS) && } - // 延迟加载字体 + // 延迟加载fontAwesome React.useEffect(() => { - loadFont() + loadExternalResource(BLOG.FONT_AWESOME_PATH, 'css') }, []) return ( @@ -62,13 +62,4 @@ const MyApp = ({ Component, pageProps }) => { ) } -/** - * 延迟加载字体 - */ -const loadFont = () => { - loadExternalResource(BLOG.FONT_AWESOME_PATH, 'css') - for (const fontUrl of BLOG.CUSTOM_FONT_URL) { - loadExternalResource(fontUrl, 'css') - } -} export default MyApp diff --git a/tailwind.config.js b/tailwind.config.js index 829bee9f..5079e173 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,5 +1,5 @@ const BLOG = require('./blog.config') -const fontFamilies = require('./lib/font') +const { fontFamilies } = require('./lib/font') module.exports = { purge: ['./pages/**/*.js', './components/**/*.js', './layouts/**/*.js', './themes/**/*.js'],