Skip to content

Commit 832e145

Browse files
committed
2 parents fd73919 + 27b0eed commit 832e145

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1356
-1125
lines changed

.env.local

+1-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.5
2+
NEXT_PUBLIC_VERSION=4.4.6
33

44

55
# 可在此添加环境变量,去掉最左边的(# )注释即可

blog.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const BLOG = {
99
THEME: process.env.NEXT_PUBLIC_THEME || 'hexo', // 当前主题,在themes文件夹下可找到所有支持的主题;主题名称就是文件夹名,例如 example,fukasawa,gitbook,heo,hexo,landing,matery,medium,next,nobelium,plog,simple
1010
THEME_SWITCH: process.env.NEXT_PUBLIC_THEME_SWITCH || false, // 是否显示切换主题按钮
1111
LANG: process.env.NEXT_PUBLIC_LANG || 'zh-CN', // e.g 'zh-CN','en-US' see /lib/lang.js for more.
12-
SINCE: process.env.NEXT_SINCE || 2021, // e.g if leave this empty, current year will be used.
12+
SINCE: process.env.NEXT_PUBLIC_SINCE || 2021, // e.g if leave this empty, current year will be used.
1313
APPEARANCE: process.env.NEXT_PUBLIC_APPEARANCE || 'light', // ['light', 'dark', 'auto'], // light 日间模式 , dark夜间模式, auto根据时间和主题自动夜间模式
1414
APPEARANCE_DARK_TIME: process.env.NEXT_PUBLIC_APPEARANCE_DARK_TIME || [18, 6], // 夜间模式起至时间,false时关闭根据时间自动切换夜间模式
1515

components/ExternalPlugins.js

+8-14
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ const ExternalPlugin = props => {
100100
const CHATBASE_ID = siteConfig('CHATBASE_ID')
101101
const COMMENT_DAO_VOICE_ID = siteConfig('COMMENT_DAO_VOICE_ID')
102102
const AD_WWADS_ID = siteConfig('AD_WWADS_ID')
103-
const COMMENT_TWIKOO_ENV_ID = siteConfig('COMMENT_TWIKOO_ENV_ID')
104-
const COMMENT_TWIKOO_CDN_URL = siteConfig('COMMENT_TWIKOO_CDN_URL')
103+
// const COMMENT_TWIKOO_ENV_ID = siteConfig('COMMENT_TWIKOO_ENV_ID')
104+
// const COMMENT_TWIKOO_CDN_URL = siteConfig('COMMENT_TWIKOO_CDN_URL')
105105
const COMMENT_ARTALK_SERVER = siteConfig('COMMENT_ARTALK_SERVER')
106106
const COMMENT_ARTALK_JS = siteConfig('COMMENT_ARTALK_JS')
107107
const COMMENT_TIDIO_ID = siteConfig('COMMENT_TIDIO_ID')
@@ -152,12 +152,16 @@ const ExternalPlugin = props => {
152152
}
153153

154154
useEffect(() => {
155+
// 异步渲染谷歌广告
155156
if (ADSENSE_GOOGLE_ID) {
156157
setTimeout(() => {
157-
// 异步渲染谷歌广告
158158
initGoogleAdsense()
159159
}, 1000)
160160
}
161+
162+
// 执行注入脚本
163+
// eslint-disable-next-line no-eval
164+
eval(GLOBAL_JS)
161165
}, [])
162166

163167
if (DISABLE_PLUGIN) {
@@ -206,16 +210,6 @@ const ExternalPlugin = props => {
206210
</>
207211
)}
208212

209-
{/* 注入JS脚本 */}
210-
{GLOBAL_JS && (
211-
<script
212-
async
213-
dangerouslySetInnerHTML={{
214-
__html: GLOBAL_JS
215-
}}
216-
/>
217-
)}
218-
219213
{CHATBASE_ID && (
220214
<>
221215
<script
@@ -285,7 +279,7 @@ const ExternalPlugin = props => {
285279
async></script>
286280
)}
287281

288-
{COMMENT_TWIKOO_ENV_ID && <script defer src={COMMENT_TWIKOO_CDN_URL} />}
282+
{/* {COMMENT_TWIKOO_ENV_ID && <script defer src={COMMENT_TWIKOO_CDN_URL} />} */}
289283

290284
{COMMENT_ARTALK_SERVER && <script defer src={COMMENT_ARTALK_JS} />}
291285

components/GlobalHead.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { useEffect } from 'react'
1111
* @returns
1212
*/
1313
const GlobalHead = props => {
14-
const { children, siteInfo } = props
14+
const { children, siteInfo, post } = props
1515
let url = siteConfig('PATH')?.length
1616
? `${siteConfig('LINK')}/${siteConfig('SUB_PATH', '')}`
1717
: siteConfig('LINK')
@@ -25,12 +25,17 @@ const GlobalHead = props => {
2525
const title = meta?.title || siteConfig('TITLE')
2626
const description = meta?.description || `${siteInfo?.description}`
2727
const type = meta?.type || 'website'
28-
const keywords = meta?.tags || siteConfig('KEYWORDS')
2928
const lang = siteConfig('LANG').replace('-', '_') // Facebook OpenGraph 要 zh_CN 這樣的格式才抓得到語言
3029
const category = meta?.category || siteConfig('KEYWORDS') // section 主要是像是 category 這樣的分類,Facebook 用這個來抓連結的分類
3130
const favicon = siteConfig('BLOG_FAVICON')
3231
const webFontUrl = siteConfig('FONT_URL')
3332

33+
// SEO关键词
34+
let keywords = meta?.tags || siteConfig('KEYWORDS')
35+
if (post?.tags && post?.tags?.length > 0) {
36+
keywords = post?.tags?.join(',')
37+
}
38+
3439
useEffect(() => {
3540
// 使用WebFontLoader字体加载
3641
loadExternalResource(

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.5",
3+
"version": "4.4.6",
44
"homepage": "https://github.com/tangly1024/NotionNext.git",
55
"license": "MIT",
66
"repository": {

themes/example/components/Announcement.js

+19-9
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,30 @@ import dynamic from 'next/dynamic'
33

44
const NotionPage = dynamic(() => import('@/components/NotionPage'))
55

6+
/**
7+
* 公告模块
8+
* 其实就是一篇文章
9+
* @param {*} param0
10+
* @returns
11+
*/
612
const Announcement = ({ post, className }) => {
713
const { locale } = useGlobal()
814
if (!post || Object.keys(post).length === 0) {
915
return <></>
1016
}
11-
return <aside className="rounded shadow overflow-hidden mb-6">
17+
return (
18+
<aside className='rounded shadow overflow-hidden mb-6'>
19+
<h3 className='text-sm bg-gray-100 text-gray-700 dark:bg-hexo-black-gray dark:text-gray-200 py-3 px-4 dark:border-hexo-black-gray border-b'>
20+
<i className='mr-2 fas fa-bullhorn' />
21+
{locale.COMMON.ANNOUNCEMENT}
22+
</h3>
1223

13-
<h3 className="text-sm bg-gray-100 text-gray-700 dark:bg-hexo-black-gray dark:text-gray-200 py-3 px-4 dark:border-hexo-black-gray border-b">
14-
<i className="mr-2 fas fa-bullhorn" />{locale.COMMON.ANNOUNCEMENT}
15-
</h3>
16-
17-
{post && (<div id="announcement-content">
18-
<NotionPage post={post} className='text-center ' />
19-
</div>)}
20-
</aside>
24+
{post && (
25+
<div id='announcement-content'>
26+
<NotionPage post={post} className='text-center' />
27+
</div>
28+
)}
29+
</aside>
30+
)
2131
}
2232
export default Announcement

themes/example/components/ArticleInfo.js

-51
This file was deleted.

themes/example/components/ArticleLock.js

-52
This file was deleted.

themes/example/components/BlogItem.js

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import LazyImage from '@/components/LazyImage'
2+
import NotionIcon from '@/components/NotionIcon'
3+
import TwikooCommentCount from '@/components/TwikooCommentCount'
4+
import { siteConfig } from '@/lib/config'
5+
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
6+
import Link from 'next/link'
7+
import CONFIG from '../config'
8+
9+
/**
10+
* 博客列表的单个卡片
11+
* @param {*} param0
12+
* @returns
13+
*/
14+
const BlogItem = ({ post }) => {
15+
const showPageCover =
16+
siteConfig('EXAMPLE_POST_LIST_COVER', null, CONFIG) &&
17+
post?.pageCoverThumbnail
18+
const url = checkContainHttp(post.slug)
19+
? sliceUrlFromHttp(post.slug)
20+
: `${siteConfig('SUB_PATH', '')}/${post.slug}`
21+
22+
return (
23+
<article
24+
className={`${showPageCover ? 'flex md:flex-row flex-col-reverse' : ''} replace mb-12 `}>
25+
<div className={`${showPageCover ? 'md:w-7/12' : ''}`}>
26+
<h2 className='mb-4'>
27+
<Link
28+
href={`/${post.slug}`}
29+
className='text-black dark:text-gray-100 text-xl md:text-2xl no-underline hover:underline'>
30+
{siteConfig('POST_TITLE_ICON') && (
31+
<NotionIcon icon={post.pageIcon} />
32+
)}
33+
{post?.title}
34+
</Link>
35+
</h2>
36+
37+
<div className='mb-4 text-sm text-gray-700 dark:text-gray-300'>
38+
by{' '}
39+
<a href='#' className='text-gray-700 dark:text-gray-300'>
40+
{siteConfig('AUTHOR')}
41+
</a>{' '}
42+
on {post.date?.start_date || post.createdTime}
43+
<TwikooCommentCount post={post} className='pl-1' />
44+
{post.category && (
45+
<>
46+
<span className='font-bold mx-1'> | </span>
47+
<Link
48+
href={`/category/${post.category}`}
49+
className='text-gray-700 dark:text-gray-300 hover:underline'>
50+
{post.category}
51+
</Link>
52+
</>
53+
)}
54+
{/* <span className="font-bold mx-1"> | </span> */}
55+
{/* <a href="#" className="text-gray-700">2 Comments</a> */}
56+
</div>
57+
58+
{!post.results && (
59+
<p className='line-clamp-3 text-gray-700 dark:text-gray-400 leading-normal'>
60+
{post.summary}
61+
</p>
62+
)}
63+
{/* 搜索结果 */}
64+
{post.results && (
65+
<p className='line-clamp-3 mt-4 text-gray-700 dark:text-gray-300 text-sm font-light leading-7'>
66+
{post.results.map((r, index) => (
67+
<span key={index}>{r}</span>
68+
))}
69+
</p>
70+
)}
71+
</div>
72+
{/* 图片封面 */}
73+
{showPageCover && (
74+
<div className='md:w-5/12 w-full h-44 overflow-hidden p-1'>
75+
<Link href={url} passHref legacyBehavior>
76+
<LazyImage
77+
src={post?.pageCoverThumbnail}
78+
className='w-full bg-cover hover:scale-110 duration-200'
79+
/>
80+
</Link>
81+
</div>
82+
)}
83+
</article>
84+
)
85+
}
86+
87+
export default BlogItem
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { siteConfig } from '@/lib/config'
2+
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
3+
import Link from 'next/link'
4+
5+
/**
6+
* 博客归档列表;仅归档页面使用
7+
* 按照日期将文章分组
8+
* @param {*} param0
9+
* @returns
10+
*/
11+
export default function BlogListArchive({ archiveTitle, archivePosts }) {
12+
return (
13+
<div key={archiveTitle}>
14+
<div id={archiveTitle} className='pt-16 pb-4 text-3xl dark:text-gray-300'>
15+
{archiveTitle}
16+
</div>
17+
18+
<ul>
19+
{archivePosts[archiveTitle].map(post => {
20+
const url = checkContainHttp(post.slug)
21+
? sliceUrlFromHttp(post.slug)
22+
: `${siteConfig('SUB_PATH', '')}/${post.slug}`
23+
24+
return (
25+
<li
26+
key={post.id}
27+
className='border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500'>
28+
<div id={post?.publishDay}>
29+
<span className='text-gray-400'>{post?.publishDay}</span> &nbsp;
30+
<Link
31+
href={url}
32+
className='dark:text-gray-400 dark:hover:text-gray-300 overflow-x-hidden hover:underline cursor-pointer text-gray-600'>
33+
{post.title}
34+
</Link>
35+
</div>
36+
</li>
37+
)
38+
})}
39+
</ul>
40+
</div>
41+
)
42+
}

0 commit comments

Comments
 (0)