diff --git a/components/ExternalScript.js b/components/ExternalScript.js index 66fe457c..f10efa72 100644 --- a/components/ExternalScript.js +++ b/components/ExternalScript.js @@ -1,13 +1,14 @@ +'use client' + import BLOG from '@/blog.config' -import { loadExternalResource } from '@/lib/utils' -import { useEffect } from 'react' +import { isBrowser, loadExternalResource } from '@/lib/utils' /** * 自定义引入外部JS 和 CSS * @returns */ const ExternalScript = () => { - useEffect(() => { + if (isBrowser()) { // 静态导入本地自定义样式 loadExternalResource(BLOG.FONT_AWESOME, 'css') loadExternalResource('/css/custom.css', 'css') @@ -30,10 +31,9 @@ const ExternalScript = () => { } // 渲染所有字体 BLOG.FONT_URL?.forEach(e => { - loadExternalResource(e, 'css') + loadExternalResource(e, 'font') }) - }, []) - + } return null } diff --git a/pages/_app.js b/pages/_app.js index d20f396c..650158b6 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -28,9 +28,9 @@ const MyApp = ({ Component, pageProps }) => { return ( + - ) } diff --git a/themes/example/components/BlogPostCard.js b/themes/example/components/BlogPostCard.js index 03f38ec6..faf1753d 100644 --- a/themes/example/components/BlogPostCard.js +++ b/themes/example/components/BlogPostCard.js @@ -2,6 +2,7 @@ import BLOG from '@/blog.config' import CONFIG from '../config' import Link from 'next/link' import TwikooCommentCount from '@/components/TwikooCommentCount' +import LazyImage from '@/components/LazyImage' const BlogPostCard = ({ post }) => { const showPageCover = CONFIG.POST_LIST_COVER && post?.pageCoverThumbnail @@ -41,7 +42,7 @@ const BlogPostCard = ({ post }) => { {showPageCover && (
-
+
)} diff --git a/themes/heo/components/ArticleRecommend.js b/themes/heo/components/ArticleRecommend.js index 8679a2e8..f7f6c738 100644 --- a/themes/heo/components/ArticleRecommend.js +++ b/themes/heo/components/ArticleRecommend.js @@ -2,6 +2,7 @@ import Link from 'next/link' import CONFIG from '../config' import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' +import LazyImage from '@/components/LazyImage' /** * 关联推荐文章 @@ -35,8 +36,8 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) {
{recommendPosts.map(post => { const headerImage = post?.pageCoverThumbnail - ? `url("${post.pageCoverThumbnail}")` - : `url("${siteInfo?.pageCover}")` + ? post.pageCoverThumbnail + : siteInfo?.pageCover return ( ( -
-
-
+
+
+
{post.title}
+
) diff --git a/themes/heo/components/BlogPostArchive.js b/themes/heo/components/BlogPostArchive.js index 0b092fb2..4f471444 100644 --- a/themes/heo/components/BlogPostArchive.js +++ b/themes/heo/components/BlogPostArchive.js @@ -3,6 +3,7 @@ import Link from 'next/link' import BLOG from '@/blog.config' import CONFIG from '../config' import TagItemMini from './TagItemMini' +import LazyImage from '@/components/LazyImage' /** * 博客归档列表 * @param posts 所有文章 @@ -29,13 +30,13 @@ const BlogPostArchive = ({ posts = [], archiveTitle, siteInfo }) => { post.pageCoverThumbnail = siteInfo?.pageCover } const showPageCover = CONFIG.POST_LIST_COVER && post?.pageCoverThumbnail && !showPreview - return
+ return
{/* 图片封面 */} {showPageCover && (
-
+
)} @@ -44,7 +45,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle, siteInfo }) => {
{/* 分类 */} - {post?.category &&