Skip to content

Commit d410b75

Browse files
committed
2 parents 6f6844d + 2dd9be9 commit d410b75

File tree

37 files changed

+179
-146
lines changed

37 files changed

+179
-146
lines changed

.env.local

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
2-
NEXT_PUBLIC_VERSION=4.4.3
2+
NEXT_PUBLIC_VERSION=4.4.4
33

44

55
# 可在此添加环境变量,去掉最左边的(# )注释即可
@@ -62,6 +62,7 @@ NEXT_PUBLIC_VERSION=4.4.3
6262
# NEXT_PUBLIC_ALGOLIA_INDEX=
6363
# NEXT_PUBLIC_PREVIEW_CATEGORY_COUNT=
6464
# NEXT_PUBLIC_PREVIEW_TAG_COUNT=
65+
# NEXT_PUBLIC_POST_TITLE_ICON=
6566
# NEXT_PUBLIC_POST_DISABLE_GALLERY_CLICK=
6667
# NEXT_PUBLIC_FIREWORKS=
6768
# NEXT_PUBLIC_FIREWORKS_COLOR=

blog.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ const BLOG = {
221221
PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量,0为不限制
222222
PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量,0为不限制
223223

224+
POST_TITLE_ICON: process.env.NEXT_PUBLIC_POST_TITLE_ICON || true, // 是否显示标题icon
224225
POST_DISABLE_GALLERY_CLICK:
225226
process.env.NEXT_PUBLIC_POST_DISABLE_GALLERY_CLICK || false, // 画册视图禁止点击,方便在友链页面的画册插入链接
226227

components/GlobalHead.js

+54-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { siteConfig } from '@/lib/config'
22
import { useGlobal } from '@/lib/global'
3+
import { loadExternalResource } from '@/lib/utils'
34
import Head from 'next/head'
45
import { useRouter } from 'next/router'
6+
import { useEffect } from 'react'
57

68
/**
79
* 页面的Head头,通常有用于SEO
@@ -10,7 +12,9 @@ import { useRouter } from 'next/router'
1012
*/
1113
const GlobalHead = props => {
1214
const { children, siteInfo } = props
13-
let url = siteConfig('PATH')?.length ? `${siteConfig('LINK')}/${siteConfig('SUB_PATH', '')}` : siteConfig('LINK')
15+
let url = siteConfig('PATH')?.length
16+
? `${siteConfig('LINK')}/${siteConfig('SUB_PATH', '')}`
17+
: siteConfig('LINK')
1418
let image
1519
const router = useRouter()
1620
const meta = getSEOMeta(props, router, useGlobal())
@@ -24,19 +28,50 @@ const GlobalHead = props => {
2428
const keywords = meta?.tags || siteConfig('KEYWORDS')
2529
const lang = siteConfig('LANG').replace('-', '_') // Facebook OpenGraph 要 zh_CN 這樣的格式才抓得到語言
2630
const category = meta?.category || siteConfig('KEYWORDS') // section 主要是像是 category 這樣的分類,Facebook 用這個來抓連結的分類
31+
const favicon = siteConfig('BLOG_FAVICON')
32+
const webFontUrl = siteConfig('FONT_URL')
33+
34+
useEffect(() => {
35+
// 使用WebFontLoader字体加载
36+
loadExternalResource(
37+
'https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js',
38+
'js'
39+
).then(url => {
40+
const WebFont = window?.WebFont
41+
if (WebFont) {
42+
console.log('LoadWebFont', webFontUrl)
43+
WebFont.load({
44+
custom: {
45+
// families: ['"LXGW WenKai"'],
46+
urls: webFontUrl
47+
}
48+
})
49+
}
50+
})
51+
}, [])
2752

2853
return (
2954
<Head>
55+
<link rel='icon' href={favicon} />
3056
<title>{title}</title>
3157
<meta name='theme-color' content={siteConfig('BACKGROUND_DARK')} />
32-
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0' />
58+
<meta
59+
name='viewport'
60+
content='width=device-width, initial-scale=1.0, maximum-scale=5.0, minimum-scale=1.0'
61+
/>
3362
<meta name='robots' content='follow, index' />
3463
<meta charSet='UTF-8' />
3564
{siteConfig('SEO_GOOGLE_SITE_VERIFICATION') && (
36-
<meta name='google-site-verification' content={siteConfig('SEO_GOOGLE_SITE_VERIFICATION')} />
65+
<meta
66+
name='google-site-verification'
67+
content={siteConfig('SEO_GOOGLE_SITE_VERIFICATION')}
68+
/>
3769
)}
3870
{siteConfig('SEO_BAIDU_SITE_VERIFICATION') && (
39-
<meta name='baidu-site-verification' content={siteConfig('SEO_BAIDU_SITE_VERIFICATION')} />
71+
<meta
72+
name='baidu-site-verification'
73+
content={siteConfig('SEO_BAIDU_SITE_VERIFICATION')}
74+
/>
4075
)}
4176
<meta name='keywords' content={keywords} />
4277
<meta name='description' content={description} />
@@ -57,13 +92,17 @@ const GlobalHead = props => {
5792
rel='webmention'
5893
href={`https://webmention.io/${siteConfig('COMMENT_WEBMENTION_HOSTNAME')}/webmention`}
5994
/>
60-
<link rel='pingback' href={`https://webmention.io/${siteConfig('COMMENT_WEBMENTION_HOSTNAME')}/xmlrpc`} />
95+
<link
96+
rel='pingback'
97+
href={`https://webmention.io/${siteConfig('COMMENT_WEBMENTION_HOSTNAME')}/xmlrpc`}
98+
/>
6199
</>
62100
)}
63101

64-
{siteConfig('COMMENT_WEBMENTION_ENABLE') && siteConfig('COMMENT_WEBMENTION_AUTH') !== '' && (
65-
<link href={siteConfig('COMMENT_WEBMENTION_AUTH')} rel='me' />
66-
)}
102+
{siteConfig('COMMENT_WEBMENTION_ENABLE') &&
103+
siteConfig('COMMENT_WEBMENTION_AUTH') !== '' && (
104+
<link href={siteConfig('COMMENT_WEBMENTION_AUTH')} rel='me' />
105+
)}
67106

68107
{JSON.parse(siteConfig('ANALYTICS_BUSUANZI_ENABLE')) && (
69108
<meta name='referrer' content='no-referrer-when-downgrade' />
@@ -73,7 +112,10 @@ const GlobalHead = props => {
73112
<meta property='article:published_time' content={meta.publishDay} />
74113
<meta property='article:author' content={siteConfig('AUTHOR')} />
75114
<meta property='article:section' content={category} />
76-
<meta property='article:publisher' content={siteConfig('FACEBOOK_PAGE')} />
115+
<meta
116+
property='article:publisher'
117+
content={siteConfig('FACEBOOK_PAGE')}
118+
/>
77119
</>
78120
)}
79121
{children}
@@ -181,7 +223,9 @@ const getSEOMeta = (props, router, global) => {
181223
}
182224
default:
183225
return {
184-
title: post ? `${post?.title} | ${siteInfo?.title}` : `${siteInfo?.title} | loading`,
226+
title: post
227+
? `${post?.title} | ${siteInfo?.title}`
228+
: `${siteInfo?.title} | loading`,
185229
description: post?.summary,
186230
type: post?.type,
187231
slug: post?.slug,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "notion-next",
3-
"version": "4.4.3",
3+
"version": "4.4.4",
44
"homepage": "https://github.com/tangly1024/NotionNext.git",
55
"license": "MIT",
66
"repository": {

pages/_app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import '@/styles/globals.css'
33
import '@/styles/utility-patterns.css'
44

55
// core styles shared by all of react-notion-x (required)
6-
// import 'react-notion-x/src/styles.css' // 原版的react-notion-x
7-
import '@/styles/notion.css' // 重写notion样式
6+
import '@/styles/notion.css' // 重写部分notion样式
7+
import 'react-notion-x/src/styles.css' // 原版的react-notion-x
88

99
import useAdjustStyle from '@/hooks/useAdjustStyle'
1010
import { GlobalContextProvider } from '@/lib/global'

pages/_document.js

-19
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,6 @@ class MyDocument extends Document {
3030
/>
3131
</>
3232
)}
33-
34-
{BLOG.FONT_URL?.map((fontUrl, index) => {
35-
if (
36-
fontUrl.endsWith('.css') ||
37-
fontUrl.includes('googleapis.com/css')
38-
) {
39-
return <link key={index} rel='stylesheet' href={fontUrl} />
40-
} else {
41-
return (
42-
<link
43-
key={index}
44-
rel='preload'
45-
href={fontUrl}
46-
as='font'
47-
type='font/woff2'
48-
/>
49-
)
50-
}
51-
})}
5233
</Head>
5334

5435
<body>

themes/commerce/components/PostHeader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function PostHeader({ post }) {
2929

3030
{/* 文章Title */}
3131
<div className="leading-snug font-bold xs:text-4xl sm:text-4xl md:text-5xl md:leading-snug text-4xl shadow-text-md flex justify-center text-center text-white">
32-
<NotionIcon icon={post.pageIcon} className='text-4xl mx-1' /><div className='text-4xl mx-1'>{post.title}</div>
32+
{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post.pageIcon} className='text-4xl mx-1' />}<div className='text-4xl mx-1'>{post.title}</div>
3333
</div>
3434

3535
</div>

themes/example/components/BlogPostCard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const BlogPostCard = ({ post }) => {
1616
<Link
1717
href={`/${post.slug}`}
1818
className="text-black dark:text-gray-100 text-xl md:text-2xl no-underline hover:underline">
19-
<NotionIcon icon={post.pageIcon} />{post?.title}
19+
{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post.pageIcon} />}{post?.title}
2020
</Link>
2121
</h2>
2222

themes/example/components/Title.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const Title = (props) => {
1212
const description = post?.description || siteConfig('AUTHOR')
1313

1414
return <div className="text-center px-6 py-12 mb-6 bg-gray-100 dark:bg-hexo-black-gray dark:border-hexo-black-gray border-b">
15-
<h1 className="text-xl md:text-4xl pb-4"><NotionIcon icon={post?.pageIcon} />{title}</h1>
15+
<h1 className="text-xl md:text-4xl pb-4">{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post?.pageIcon} />}{title}</h1>
1616
<p className="leading-loose text-gray-dark">
1717
{description}
1818
</p>

themes/fukasawa/components/ArticleDetail.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import LazyImage from '@/components/LazyImage'
1010
import { formatDateFmt } from '@/lib/utils/formatDate'
1111
import WWAds from '@/components/WWAds'
1212
import NotionIcon from '@/components/NotionIcon'
13+
import { siteConfig } from '@/lib/config'
1314

1415
/**
1516
*
@@ -37,7 +38,7 @@ export default function ArticleDetail(props) {
3738

3839
{/* 文章Title */}
3940
<div className="font-bold text-4xl text-black dark:text-white">
40-
<NotionIcon icon={post?.pageIcon} />{post.title}
41+
{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post?.pageIcon} />}{post.title}
4142
</div>
4243

4344
<section className="flex-wrap flex mt-2 text-gray-400 dark:text-gray-400 font-light leading-8">

themes/fukasawa/components/BlogCard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const BlogCard = ({ index, post, showSummary, siteInfo }) => {
7171
passHref
7272
href={url}
7373
className={`break-words cursor-pointer font-bold hover:underline text-xl ${showPreview ? 'justify-center' : 'justify-start'} leading-tight text-gray-700 dark:text-gray-100 hover:text-blue-500 dark:hover:text-blue-400`}>
74-
<NotionIcon icon={post.pageIcon} /> {post.title}
74+
{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post.pageIcon} />} {post.title}
7575
</Link>
7676
</h2>
7777

themes/game/components/BlogPost.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const BlogPost = ({ post }) => {
1515
<article key={post.id} className="mb-6 md:mb-8">
1616
<header className="flex flex-col justify-between md:flex-row md:items-baseline">
1717
<h2 className="text-lg md:text-xl font-medium mb-2 cursor-pointer text-black dark:text-gray-100">
18-
<NotionIcon icon={post.pageIcon} />{post.title}
18+
{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post.pageIcon} />}{post.title}
1919
</h2>
2020
<time className="flex-shrink-0 text-gray-600 dark:text-gray-400">
2121
{post?.publishDay}

themes/game/components/PostInfo.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import NotionIcon from '@/components/NotionIcon'
22
import Link from 'next/link'
33
import TagItem from './TagItem'
4+
import { siteConfig } from '@/lib/config'
45

56
/**
67
* 文章详情页说明信息
@@ -25,7 +26,7 @@ export default function PostInfo(props) {
2526
</div>
2627

2728
<h1 className='font-bold text-3xl text-black dark:text-white'>
28-
<NotionIcon icon={post?.pageIcon} />
29+
{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post?.pageIcon} />}
2930
{post?.title}
3031
</h1>
3132

themes/gitbook/components/BlogPostCard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const BlogPostCard = ({ post, className }) => {
1414
<Link href={url} passHref>
1515
<div key={post.id} className={`${className} relative py-1.5 cursor-pointer px-1.5 hover:bg-gray-50 rounded-md dark:hover:bg-gray-600 ${currentSelected ? 'bg-green-50 text-green-500 dark:bg-yellow-100 dark:text-yellow-600' : ''}`}>
1616
<div className="w-full select-none">
17-
<NotionIcon icon={post?.pageIcon}/> {post.title}
17+
{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post?.pageIcon} />} {post.title}
1818
</div>
1919
{/* 最新文章加个红点 */}
2020
{post?.isLatest && siteConfig('GITBOOK_LATEST_POST_RED_BADGE', false, CONFIG) && <Badge/>}

themes/gitbook/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ const LayoutSlug = (props) => {
275275
{!lock && <div id='container'>
276276

277277
{/* title */}
278-
<h1 className="text-3xl pt-12 dark:text-gray-300"><NotionIcon icon={post?.pageIcon} />{post?.title}</h1>
278+
<h1 className="text-3xl pt-12 dark:text-gray-300">{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post?.pageIcon} />}{post?.title}</h1>
279279

280280
{/* Notion文章主体 */}
281281
{post && (<section id="article-wrapper" className="px-1">

themes/heo/components/BlogPostCard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const BlogPostCard = ({ index, post, showSummary, siteInfo }) => {
4444
href={url}
4545
passHref
4646
className={' group-hover:text-indigo-700 dark:hover:text-yellow-700 dark:group-hover:text-yellow-600 text-black dark:text-gray-100 line-clamp-2 replace cursor-pointer text-xl font-extrabold leading-tight'}>
47-
<NotionIcon icon={post.pageIcon} /><span className='menu-link '>{post.title}</span>
47+
{siteConfig('POST_TITLE_ICON') && <NotionIcon icon={post.pageIcon} />}<span className='menu-link '>{post.title}</span>
4848
</Link>
4949
</header>
5050

0 commit comments

Comments
 (0)