Skip to content

Commit 93bfceb

Browse files
author
WangYang
authored
Merge branch 'tangly1024:main' into main
2 parents 2e5e2de + fc478a9 commit 93bfceb

File tree

307 files changed

+14280
-8401
lines changed

Some content is hidden

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

307 files changed

+14280
-8401
lines changed

.env.local

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

44

55
# 可在此添加环境变量,去掉最左边的(# )注释即可
66
# Notion页面ID,必须
7-
# NOTION_PAGE_ID=
7+
# NOTION_PAGE_ID=097e5f674880459d8e1b4407758dc4fb
88

99
# 非必须
1010
# NEXT_PUBLIC_PSEUDO_STATIC=
1111
# NEXT_PUBLIC_REVALIDATE_SECOND=
12-
# NEXT_PUBLIC_THEME=
12+
# NEXT_PUBLIC_THEME=matery
1313
# NEXT_PUBLIC_THEME_SWITCH=
1414
# NEXT_PUBLIC_LANG=
1515
# NEXT_PUBLIC_APPEARANCE=

.github/ISSUE_TEMPLATE/bug_report.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ assignees: tangly1024
2727

2828
- 【必填】NotionNext版本 [例如. 4.0.18]
2929
- 【必填】主题 [例如. hexo]
30+
- 【必填】部署方案 [例如. vercel]
3031
- 【可选】操作系统: [例如. iOS, Android, macOS, windows]
3132
- 【可选】浏览器 [例如. chrome, safari, firefox]
3233

.gitignore

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ yarn-error.log*
3636

3737
# dev
3838
/data.json
39-
/yarn.lock
4039
/pnpm-lock.yaml
4140
.idea
4241
.vscode
@@ -45,4 +44,9 @@ yarn-error.log*
4544
# sitemap
4645
/public/robots.txt
4746
/public/sitemap.xml
48-
/public/rss/*
47+
/public/rss/*
48+
49+
50+
# yarn
51+
package-lock.json
52+
# yarn.lock

blog.config.js

+46-4
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,17 @@ const BLOG = {
3737

3838
BLOG_FAVICON: process.env.NEXT_PUBLIC_FAVICON || '/favicon.png', // blog favicon 配置, 默认使用 /public/favicon.ico,支持在线图片,如 https://img.imesong.com/favicon.png
3939

40+
IMAGE_COMPRESS_WIDTH: process.env.NEXT_PUBLIC_IMAGE_COMPRESS_WIDTH || 800, // 图片压缩宽度默认值,作用于博客封面和文章内容 越小加载图片越快
41+
IMAGE_ZOOM_IN_WIDTH: process.env.NEXT_PUBLIC_IMAGE_ZOOM_IN_WIDTH || 1200, // 文章图片点击放大后的画质宽度,不代表在网页中的实际展示宽度
4042
RANDOM_IMAGE_URL: process.env.NEXT_PUBLIC_RANDOM_IMAGE_URL || '', // 随机图片API,如果未配置下面的关键字,主页封面,头像,文章封面图都会被替换为随机图片
4143
RANDOM_IMAGE_REPLACE_TEXT: process.env.NEXT_PUBLIC_RANDOM_IMAGE_NOT_REPLACE_TEXT || 'images.unsplash.com', // 触发替换图片的 url 关键字(多个支持用英文逗号分开),只有图片地址中包含此关键字才会替换为上方随机图片url
4244
// eg: images.unsplash.com(notion图床的所有图片都会替换),如果你在 notion 里已经添加了一个随机图片 url,恰巧那个服务跑路或者挂掉,想一键切换所有配图可以将该 url 配置在这里
4345
// 默认下会将你上传到 notion的主页封面图和头像也给替换,建议将主页封面图和头像放在其他图床,在 notion 里配置 link 即可。
4446

4547
// START ************网站字体*****************
46-
47-
FONT_STYLE: process.env.NEXT_PUBLIC_FONT_STYLE || 'font-sans', // ['font-serif','font-sans'] 两种可选,分别是衬线和无衬线: 参考 https://www.jianshu.com/p/55e410bd2115
48+
// ['font-serif','font-sans'] 两种可选,分别是衬线和无衬线: 参考 https://www.jianshu.com/p/55e410bd2115
49+
// 后面空格隔开的font-light的字体粗细,留空是默认粗细;参考 https://www.tailwindcss.cn/docs/font-weight
50+
FONT_STYLE: process.env.NEXT_PUBLIC_FONT_STYLE || 'font-sans font-light',
4851
// 字体CSS 例如 https://npm.elemecdn.com/[email protected]/style.css
4952
FONT_URL: [
5053
// 'https://npm.elemecdn.com/[email protected]/style.css',
@@ -88,8 +91,33 @@ const BLOG = {
8891
FONT_AWESOME: process.env.NEXT_PUBLIC_FONT_AWESOME_PATH || 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css', // font-awesome 字体图标地址; 可选 /css/all.min.css , https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css
8992

9093
// END ************网站字体*****************
94+
95+
// 路径和组件映射,不同路径分别展示主题的什么组件
96+
LAYOUT_MAPPINGS: {
97+
'-1': 'LayoutBase',
98+
'/': 'LayoutIndex',
99+
'/archive': 'LayoutArchive',
100+
'/page/[page]': 'LayoutPostList',
101+
'/category/[category]': 'LayoutPostList',
102+
'/category/[category]/page/[page]': 'LayoutPostList',
103+
'/tag/[tag]': 'LayoutPostList',
104+
'/tag/[tag]/page/[page]': 'LayoutPostList',
105+
'/search': 'LayoutSearch',
106+
'/search/[keyword]': 'LayoutSearch',
107+
'/search/[keyword]/page/[page]': 'LayoutSearch',
108+
'/404': 'Layout404',
109+
'/tag': 'LayoutTagIndex',
110+
'/category': 'LayoutCategoryIndex',
111+
'/[prefix]': 'LayoutSlug',
112+
'/[prefix]/[slug]': 'LayoutSlug',
113+
'/[prefix]/[slug]/[...suffix]': 'LayoutSlug',
114+
'/signin': 'LayoutSignIn',
115+
'/signup': 'LayoutSignUp'
116+
},
117+
91118
CAN_COPY: process.env.NEXT_PUBLIC_CAN_COPY || true, // 是否允许复制页面内容 默认允许,如果设置为false、则全栈禁止复制内容。
92119
CUSTOM_RIGHT_CLICK_CONTEXT_MENU: process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU || true, // 自定义右键菜单,覆盖系统菜单
120+
CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_SWITCH: process.env.NEXT_PUBLIC_CUSTOM_RIGHT_CLICK_CONTEXT_MENU_THEME_SWITCH || true, // 右键菜单是否允许切换主题
93121

94122
// 自定义外部脚本,外部样式
95123
CUSTOM_EXTERNAL_JS: [''], // e.g. ['http://xx.com/script.js','http://xx.com/script.js']
@@ -150,6 +178,8 @@ const BLOG = {
150178
POSTS_PER_PAGE: 12, // post counts per page
151179
POSTS_SORT_BY: process.env.NEXT_PUBLIC_POST_SORT_BY || 'date', // 排序方式 'date'按时间,'notion'由notion控制
152180

181+
POST_WAITING_TIME_FOR_404: process.env.NEXT_PUBLIC_POST_WAITING_TIME_FOR_404 || '8', // 文章加载超时时间,单位秒;超时后跳转到404页面
182+
153183
ALGOLIA_APP_ID: process.env.NEXT_PUBLIC_ALGOLIA_APP_ID || null, // 在这里查看 https://dashboard.algolia.com/account/api-keys/
154184
ALGOLIA_ADMIN_APP_KEY: process.env.ALGOLIA_ADMIN_APP_KEY || null, // 管理后台的KEY,不要暴露在代码中,在这里查看 https://dashboard.algolia.com/account/api-keys/
155185
ALGOLIA_SEARCH_ONLY_APP_KEY: process.env.NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_APP_KEY || null, // 客户端搜索用的KEY
@@ -184,13 +214,20 @@ const BLOG = {
184214
STARRY_SKY: process.env.NEXT_PUBLIC_STARRY_SKY || false, // 开关
185215

186216
// ********挂件组件相关********
217+
// AI 文章摘要生成 @see https://docs_s.tianli0.top/
218+
TianliGPT_CSS: process.env.NEXT_PUBLIC_TIANLI_GPT_CSS || 'https://cdn1.tianli0.top/gh/zhheo/[email protected]/tianli_gpt.css',
219+
TianliGPT_JS: process.env.NEXT_PUBLIC_TIANLI_GPT_JS || 'https://cdn1.tianli0.top/gh/zhheo/[email protected]/tianli_gpt.js',
220+
TianliGPT_KEY: process.env.NEXT_PUBLIC_TIANLI_GPT_KEY || '',
221+
187222
// Chatbase 是否显示chatbase机器人 https://www.chatbase.co/
188223
CHATBASE_ID: process.env.NEXT_PUBLIC_CHATBASE_ID || null,
189224
// WebwhizAI 机器人 @see https://github.com/webwhiz-ai/webwhiz
190225
WEB_WHIZ_ENABLED: process.env.NEXT_PUBLIC_WEB_WHIZ_ENABLED || false, // 是否显示
191226
WEB_WHIZ_BASE_URL: process.env.NEXT_PUBLIC_WEB_WHIZ_BASE_URL || 'https://api.webwhiz.ai', // 可以自建服务器
192227
WEB_WHIZ_CHAT_BOT_ID: process.env.NEXT_PUBLIC_WEB_WHIZ_CHAT_BOT_ID || null, // 在后台获取ID
193-
228+
DIFY_CHATBOT_ENABLED: process.env.NEXT_PUBLIC_DIFY_CHATBOT_ENABLED || false,
229+
DIFY_CHATBOT_BASE_URL: process.env.NEXT_PUBLIC_DIFY_CHATBOT_BASE_URL || '',
230+
DIFY_CHATBOT_TOKEN: process.env.NEXT_PUBLIC_DIFY_CHATBOT_TOKEN || '',
194231
// 悬浮挂件
195232
WIDGET_PET: process.env.NEXT_PUBLIC_WIDGET_PET || true, // 是否显示宠物挂件
196233
WIDGET_PET_LINK:
@@ -236,6 +273,8 @@ const BLOG = {
236273
// ********挂件组件相关********
237274
// ----> 评论互动 可同时开启多个支持 WALINE VALINE GISCUS CUSDIS UTTERRANCES GITALK
238275

276+
COMMENT_HIDE_SINGLE_TAB: process.env.NEXT_PUBLIC_COMMENT_HIDE_SINGLE_TAB || false, // Whether hide the tab when there's no tabs. 只有一个评论组件时是否隐藏切换组件的标签页
277+
239278
// artalk 评论插件
240279
COMMENT_ARTALK_SERVER: process.env.NEXT_PUBLIC_COMMENT_ARTALK_SERVER || '', // ArtalkServert后端地址 https://artalk.js.org/guide/deploy.html
241280
COMMENT_ARTALK_JS: process.env.NEXT_PUBLIC_COMMENT_ARTALK_JS || 'https://cdnjs.cloudflare.com/ajax/libs/artalk/2.5.5/Artalk.js', // ArtalkServert js cdn
@@ -342,6 +381,9 @@ const BLOG = {
342381
SEO_BAIDU_SITE_VERIFICATION:
343382
process.env.NEXT_PUBLIC_SEO_BAIDU_SITE_VERIFICATION || '', // Remove the value or replace it with your own google site verification code
344383

384+
// 微软 Clarity 站点分析
385+
CLARITY_ID: process.env.NEXT_PUBLIC_CLARITY_ID || null, // 只需要复制Clarity脚本中的ID部分,ID是一个十位的英文数字组合
386+
345387
// <---- 站点统计
346388

347389
// START---->营收相关
@@ -407,7 +449,7 @@ const BLOG = {
407449
// 开发相关
408450
NOTION_ACCESS_TOKEN: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public
409451
DEBUG: process.env.NEXT_PUBLIC_DEBUG || false, // 是否显示调试按钮
410-
ENABLE_CACHE: process.env.ENABLE_CACHE || process.env.npm_lifecycle_event === 'build', // 缓存在开发调试和打包过程中选择性开启,正式部署开启此功能意义不大
452+
ENABLE_CACHE: process.env.ENABLE_CACHE || process.env.npm_lifecycle_event === 'build' || process.env.npm_lifecycle_event === 'export', // 在打包过程中默认开启缓存,开发或运行时开启此功能意义不大
411453
isProd: process.env.VERCEL_ENV === 'production', // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) isProd: process.env.VERCEL_ENV === 'production' // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables)
412454
BUNDLE_ANALYZER: process.env.ANALYZE === 'true' || false, // 是否展示编译依赖内容与大小
413455
VERSION: process.env.NEXT_PUBLIC_VERSION // 版本号

components/AlgoliaSearchModal.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,41 @@ export default function AlgoliaSearchModal({ cRef }) {
6868
className: 'text-blue-600 border-b border-dashed'
6969
}
7070
})
71-
}, 150)
71+
}, 200) // 延时高亮
7272
} catch (error) {
7373
console.error('Algolia search error:', error)
7474
}
7575
}
7676

77-
const throttledHandleSearch = useRef(throttle(handleSearch, 300)) // 设置节流延迟时间
77+
// 定义节流函数,确保在用户停止输入一段时间后才会调用处理搜索的方法
78+
const throttledHandleInputChange = useRef(throttle((query) => {
79+
handleSearch(query, 0);
80+
}, 1000));
81+
82+
// 用于存储搜索延迟的计时器
83+
const searchTimer = useRef(null);
7884

7985
// 修改input的onChange事件处理函数
8086
const handleInputChange = (e) => {
81-
const query = e.target.value
82-
throttledHandleSearch.current(query, 0)
83-
}
87+
const query = e.target.value;
88+
89+
// 如果已经有计时器在等待搜索,先清除之前的计时器
90+
if (searchTimer.current) {
91+
clearTimeout(searchTimer.current);
92+
}
93+
94+
// 设置新的计时器,在用户停止输入一段时间后触发搜索
95+
searchTimer.current = setTimeout(() => {
96+
throttledHandleInputChange.current(query);
97+
}, 800);
98+
};
8499

85100
/**
86101
* 切换页码
87102
* @param {*} page
88103
*/
89104
const switchPage = (page) => {
90-
throttledHandleSearch.current(keyword, page)
105+
throttledHandleInputChange.current(keyword, page)
91106
}
92107

93108
/**

components/Artalk.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { siteConfig } from '@/lib/config'
22
import { loadExternalResource } from '@/lib/utils'
3-
// import { loadExternalResource } from '@/lib/utils'
43
import { useEffect } from 'react'
54

65
/**
7-
* Giscus评论 @see https://giscus.app/zh-CN
8-
* Contribute by @txs https://github.com/txs/NotionNext/commit/1bf7179d0af21fb433e4c7773504f244998678cb
6+
* Artalk 自托管评论系统 @see https://artalk.js.org/
97
* @returns {JSX.Element}
108
* @constructor
119
*/

components/Busuanzi.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import busuanzi from '@/lib/busuanzi'
22
import { useRouter } from 'next/router'
33
import { useGlobal } from '@/lib/global'
44
// import { useRouter } from 'next/router'
5-
import React from 'react'
5+
import { useEffect } from 'react'
66

77
let path = ''
88

99
export default function Busuanzi () {
1010
const { theme } = useGlobal()
11-
const Router = useRouter()
12-
Router.events.on('routeChangeComplete', (url, option) => {
11+
const router = useRouter()
12+
router.events.on('routeChangeComplete', (url, option) => {
1313
if (url !== path) {
1414
path = url
1515
busuanzi.fetch()
1616
}
1717
})
1818

1919
// 更换主题时更新
20-
React.useEffect(() => {
20+
useEffect(() => {
2121
if (theme) {
2222
busuanzi.fetch()
2323
}

components/Collapse.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useImperativeHandle } from 'react'
1+
import { useEffect, useImperativeHandle, useRef } from 'react'
22

33
/**
44
* 折叠面板组件,支持水平折叠、垂直折叠
@@ -7,7 +7,7 @@ import React, { useEffect, useImperativeHandle } from 'react'
77
*/
88
const Collapse = props => {
99
const { collapseRef } = props
10-
const ref = React.useRef(null)
10+
const ref = useRef(null)
1111
const type = props.type || 'vertical'
1212

1313
useImperativeHandle(collapseRef, () => {
@@ -17,8 +17,10 @@ const Collapse = props => {
1717
* @param {*} param0
1818
*/
1919
updateCollapseHeight: ({ height, increase }) => {
20-
ref.current.style.height = ref.current.scrollHeight
21-
ref.current.style.height = 'auto'
20+
if (props.isOpen) {
21+
ref.current.style.height = ref.current.scrollHeight
22+
ref.current.style.height = 'auto'
23+
}
2224
}
2325
}
2426
})

components/CommonHead.js

-73
This file was deleted.

0 commit comments

Comments
 (0)