diff --git a/.env.local b/.env.local index f6509b08..ac577f78 100644 --- a/.env.local +++ b/.env.local @@ -1,5 +1,5 @@ # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=4.4.3 +NEXT_PUBLIC_VERSION=4.4.4 # 可在此添加环境变量,去掉最左边的(# )注释即可 diff --git a/components/GlobalHead.js b/components/GlobalHead.js index 86368328..b4628917 100644 --- a/components/GlobalHead.js +++ b/components/GlobalHead.js @@ -1,7 +1,9 @@ import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' +import { loadExternalResource } from '@/lib/utils' import Head from 'next/head' import { useRouter } from 'next/router' +import { useEffect } from 'react' /** * 页面的Head头,通常有用于SEO @@ -10,7 +12,9 @@ import { useRouter } from 'next/router' */ const GlobalHead = props => { const { children, siteInfo } = props - let url = siteConfig('PATH')?.length ? `${siteConfig('LINK')}/${siteConfig('SUB_PATH', '')}` : siteConfig('LINK') + let url = siteConfig('PATH')?.length + ? `${siteConfig('LINK')}/${siteConfig('SUB_PATH', '')}` + : siteConfig('LINK') let image const router = useRouter() const meta = getSEOMeta(props, router, useGlobal()) @@ -24,19 +28,50 @@ const GlobalHead = props => { const keywords = meta?.tags || siteConfig('KEYWORDS') const lang = siteConfig('LANG').replace('-', '_') // Facebook OpenGraph 要 zh_CN 這樣的格式才抓得到語言 const category = meta?.category || siteConfig('KEYWORDS') // section 主要是像是 category 這樣的分類,Facebook 用這個來抓連結的分類 + const favicon = siteConfig('BLOG_FAVICON') + const webFontUrl = siteConfig('FONT_URL') + + useEffect(() => { + // 使用WebFontLoader字体加载 + loadExternalResource( + 'https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js', + 'js' + ).then(url => { + const WebFont = window?.WebFont + if (WebFont) { + console.log('LoadWebFont', webFontUrl) + WebFont.load({ + custom: { + // families: ['"LXGW WenKai"'], + urls: webFontUrl + } + }) + } + }) + }, []) return ( + {title} - + {siteConfig('SEO_GOOGLE_SITE_VERIFICATION') && ( - + )} {siteConfig('SEO_BAIDU_SITE_VERIFICATION') && ( - + )} @@ -57,13 +92,17 @@ const GlobalHead = props => { rel='webmention' href={`https://webmention.io/${siteConfig('COMMENT_WEBMENTION_HOSTNAME')}/webmention`} /> - + )} - {siteConfig('COMMENT_WEBMENTION_ENABLE') && siteConfig('COMMENT_WEBMENTION_AUTH') !== '' && ( - - )} + {siteConfig('COMMENT_WEBMENTION_ENABLE') && + siteConfig('COMMENT_WEBMENTION_AUTH') !== '' && ( + + )} {JSON.parse(siteConfig('ANALYTICS_BUSUANZI_ENABLE')) && ( @@ -73,7 +112,10 @@ const GlobalHead = props => { - + )} {children} @@ -181,7 +223,9 @@ const getSEOMeta = (props, router, global) => { } default: return { - title: post ? `${post?.title} | ${siteInfo?.title}` : `${siteInfo?.title} | loading`, + title: post + ? `${post?.title} | ${siteInfo?.title}` + : `${siteInfo?.title} | loading`, description: post?.summary, type: post?.type, slug: post?.slug, diff --git a/package.json b/package.json index 39e5a555..d969e088 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "notion-next", - "version": "4.4.3", + "version": "4.4.4", "homepage": "https://github.com/tangly1024/NotionNext.git", "license": "MIT", "repository": { diff --git a/pages/_document.js b/pages/_document.js index a61e2b96..adb3eb3e 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -30,25 +30,6 @@ class MyDocument extends Document { /> )} - - {BLOG.FONT_URL?.map((fontUrl, index) => { - if ( - fontUrl.endsWith('.css') || - fontUrl.includes('googleapis.com/css') - ) { - return - } else { - return ( - - ) - } - })} diff --git a/themes/matery/components/BlogPostListPage.js b/themes/matery/components/BlogPostListPage.js index 7f7c4b6f..05478669 100644 --- a/themes/matery/components/BlogPostListPage.js +++ b/themes/matery/components/BlogPostListPage.js @@ -1,5 +1,5 @@ -import BlogPostCard from './BlogPostCard' import { siteConfig } from '@/lib/config' +import BlogPostCard from './BlogPostCard' import BlogPostListEmpty from './BlogPostListEmpty' import PaginationSimple from './PaginationSimple' @@ -12,7 +12,9 @@ import PaginationSimple from './PaginationSimple' * @constructor */ const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { - const totalPage = Math.ceil(postCount / parseInt(siteConfig('POSTS_PER_PAGE'))) + const totalPage = Math.ceil( + postCount / parseInt(siteConfig('POSTS_PER_PAGE')) + ) const showPagination = postCount >= parseInt(siteConfig('POSTS_PER_PAGE')) if (!posts || posts.length === 0 || page > totalPage) { return @@ -21,12 +23,17 @@ const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => {
{/* 文章列表 */} -
- {posts?.map(post => ( -
+
+ {posts?.map((post, index) => ( +
+ {' '} + +
))}
- {showPagination && } + {showPagination && ( + + )}
) } diff --git a/themes/matery/components/Footer.js b/themes/matery/components/Footer.js index b75368b4..a2266cbb 100644 --- a/themes/matery/components/Footer.js +++ b/themes/matery/components/Footer.js @@ -3,31 +3,60 @@ import { siteConfig } from '@/lib/config' const Footer = ({ title }) => { const d = new Date() const currentYear = d.getFullYear() - const copyrightDate = (function() { - if (Number.isInteger(siteConfig('SINCE')) && siteConfig('SINCE') < currentYear) { + const copyrightDate = (function () { + if ( + Number.isInteger(siteConfig('SINCE')) && + siteConfig('SINCE') < currentYear + ) { return siteConfig('SINCE') + '-' + currentYear } return currentYear })() return ( -