Skip to content

Commit 28c60ab

Browse files
committed
merge main
2 parents 1c47364 + 2c05ef0 commit 28c60ab

File tree

106 files changed

+4356
-955
lines changed

Some content is hidden

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

106 files changed

+4356
-955
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.5.4
2+
NEXT_PUBLIC_VERSION=4.6.1
33

44

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

blog.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ const BLOG = {
545545
process.env.ENABLE_CACHE ||
546546
process.env.npm_lifecycle_event === 'build' ||
547547
process.env.npm_lifecycle_event === 'export', // 在打包过程中默认开启缓存,开发或运行时开启此功能意义不大。
548-
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)
548+
isProd: process.env.VERCEL_ENV === 'production' || process.env.EXPORT, // 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)
549549
BUNDLE_ANALYZER: process.env.ANALYZE === 'true' || false, // 是否展示编译依赖内容与大小
550550
VERSION: process.env.NEXT_PUBLIC_VERSION // 版本号
551551
}

components/AOSAnimation.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@ import { useEffect } from 'react'
1010
export default function AOSAnimation() {
1111
const initAOS = async () => {
1212
Promise.all([
13-
loadExternalResource(
14-
'https://cdn.bootcdn.net/ajax/libs/aos/2.3.4/aos.js',
15-
'js'
16-
),
17-
loadExternalResource(
18-
'https://cdn.bootcdn.net/ajax/libs/aos/2.3.4/aos.css',
19-
'css'
20-
)
13+
loadExternalResource('/js/aos.js', 'js'),
14+
loadExternalResource('/css/aos.css', 'css')
2115
]).then(() => {
2216
if (window.AOS) {
2317
window.AOS.init()

components/ExternalPlugins.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import LA51 from './LA51'
55
import TianLiGPT from './TianliGPT'
66
import WebWhiz from './Webwhiz'
77

8-
import { CUSTOM_EXTERNAL_CSS, CUSTOM_EXTERNAL_JS } from '@/blog.config'
98
import { convertInnerUrl } from '@/lib/notion/convertInnerUrl'
109
import { isBrowser, loadExternalResource } from '@/lib/utils'
1110
import { useRouter } from 'next/router'
@@ -44,8 +43,6 @@ const ExternalPlugin = props => {
4443
const CHATBASE_ID = siteConfig('CHATBASE_ID')
4544
const COMMENT_DAO_VOICE_ID = siteConfig('COMMENT_DAO_VOICE_ID')
4645
const AD_WWADS_ID = siteConfig('AD_WWADS_ID')
47-
// const COMMENT_TWIKOO_ENV_ID = siteConfig('COMMENT_TWIKOO_ENV_ID')
48-
// const COMMENT_TWIKOO_CDN_URL = siteConfig('COMMENT_TWIKOO_CDN_URL')
4946
const COMMENT_ARTALK_SERVER = siteConfig('COMMENT_ARTALK_SERVER')
5047
const COMMENT_ARTALK_JS = siteConfig('COMMENT_ARTALK_JS')
5148
const COMMENT_TIDIO_ID = siteConfig('COMMENT_TIDIO_ID')
@@ -64,6 +61,8 @@ const ExternalPlugin = props => {
6461
const IMG_SHADOW = siteConfig('IMG_SHADOW')
6562
const ANIMATE_CSS_URL = siteConfig('ANIMATE_CSS_URL')
6663
const MOUSE_FOLLOW = siteConfig('MOUSE_FOLLOW')
64+
const CUSTOM_EXTERNAL_CSS = siteConfig('CUSTOM_EXTERNAL_CSS')
65+
const CUSTOM_EXTERNAL_JS = siteConfig('CUSTOM_EXTERNAL_JS')
6766

6867
// 自定义样式css和js引入
6968
if (isBrowser) {

components/ThemeSwitch.js

+90-48
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,128 @@
11
import { useGlobal } from '@/lib/global'
2-
import { useState } from 'react'
3-
import { Draggable } from './Draggable'
2+
import LANGS from '@/lib/lang'
3+
import { getQueryParam } from '@/lib/utils'
44
import { THEMES } from '@/themes/theme'
55
import { useRouter } from 'next/router'
6+
import { useState } from 'react'
67
import DarkModeButton from './DarkModeButton'
7-
import { getQueryParam } from '@/lib/utils'
8-
import LANGS from '@/lib/lang'
8+
import { Draggable } from './Draggable'
99
/**
1010
*
1111
* @returns 主题切换
1212
*/
1313
const ThemeSwitch = () => {
14-
const { theme, lang, changeLang, locale, isDarkMode, toggleDarkMode } = useGlobal()
14+
const { theme, lang, changeLang, locale, isDarkMode, toggleDarkMode } =
15+
useGlobal()
1516
const router = useRouter()
1617
const currentTheme = getQueryParam(router.asPath, 'theme') || theme
1718
// const currentLang = getQueryParam(router.asPath, 'lang') || lang
1819
const [isLoading, setIsLoading] = useState(false)
1920

2021
// 修改当前路径url中的 theme 参数
2122
// 例如 http://localhost?theme=hexo 跳转到 http://localhost?theme=newTheme
22-
const onThemeSelectChange = (e) => {
23-
document.ontouchmove = document.ontouchend = document.onmousemove = document.onmouseup = null
23+
const onThemeSelectChange = e => {
24+
document.ontouchmove =
25+
document.ontouchend =
26+
document.onmousemove =
27+
document.onmouseup =
28+
null
2429
setIsLoading(true)
2530
const newTheme = e.target.value
2631
const query = router.query
2732
query.theme = newTheme
2833
router.push({ pathname: router.pathname, query }).then(() => {
2934
setTimeout(() => {
3035
setIsLoading(false)
31-
}, 500);
36+
}, 500)
3237
})
3338
}
3439

35-
const onLangSelectChange = (e) => {
36-
document.ontouchmove = document.ontouchend = document.onmousemove = document.onmouseup = null
40+
const onLangSelectChange = e => {
41+
document.ontouchmove =
42+
document.ontouchend =
43+
document.onmousemove =
44+
document.onmouseup =
45+
null
3746
const newLang = e.target.value
3847
changeLang(newLang)
3948
}
4049

41-
return (<>
42-
<Draggable>
43-
<div id="draggableBox" style={{ left: '0px', top: '80vh' }} className="fixed group space-y-2 overflow-hidden z-50 p-3 flex flex-col items-start dark:text-white bg-white dark:bg-black rounded-xl shadow-lg ">
44-
{/* 深色按钮 */}
45-
<div className="text-sm flex items-center w-0 group-hover:w-32 transition-all duration-200">
46-
<DarkModeButton />
47-
<div onClick={toggleDarkMode} className='cursor-pointer w-0 group-hover:w-24 transition-all duration-200 overflow-hidden whitespace-nowrap pl-1 h-auto'>{isDarkMode ? locale.MENU.DARK_MODE : locale.MENU.LIGHT_MODE}</div>
48-
</div>
50+
return (
51+
<>
52+
<Draggable>
53+
<div
54+
id='draggableBox'
55+
style={{ left: '0px', top: '80vh' }}
56+
className='fixed group flex flex-col items-start space-y-2 overflow-hidden z-50 p-3
57+
dark:text-white bg-white dark:bg-black
58+
rounded-xl shadow-lg hover:scale-105 hover:shadow-2xl '>
59+
{/* 主题切换按钮 */}
60+
<div className='text-sm flex items-center group-hover:w-32 duration-200'>
61+
<i className='fa-solid fa-palette w-5' />
62+
<div className='w-0 group-hover:w-24 duration-200 overflow-hidden'>
63+
<label htmlFor='themeSelect' className='sr-only'>
64+
{locale.COMMON.THEME}
65+
</label>
66+
<select
67+
id='themeSelect'
68+
value={currentTheme}
69+
onChange={onThemeSelectChange}
70+
name='themes'
71+
className='pl-1 bg-gray-50 dark:bg-black appearance-none outline-none dark:text-white uppercase cursor-pointer'>
72+
{THEMES?.map(t => {
73+
return (
74+
<option key={t} value={t}>
75+
{t}
76+
</option>
77+
)
78+
})}
79+
</select>
80+
</div>
81+
</div>
4982

50-
{/* 翻译按钮 */}
51-
<div className="text-sm flex items-center group-hover:w-32 transition-all duration-200">
52-
<i className="fa-solid fa-language w-5" />
53-
<div className='w-0 group-hover:w-24 transition-all duration-200 overflow-hidden'>
54-
<label htmlFor="langSelect" className="sr-only">选择语言:</label>
55-
<select id="langSelect" value={lang} onChange={onLangSelectChange} name="themes" className='pl-1 bg-gray-50 dark:bg-black appearance-none outline-none dark:text-white uppercase cursor-pointer'>
56-
{Object.keys(LANGS)?.map(t => {
57-
return <option key={t} value={t}>{LANGS[t].LOCALE}</option>
58-
})}
59-
</select>
60-
</div>
61-
</div>
83+
{/* 深色按钮 */}
84+
<div className='text-sm flex items-center w-0 group-hover:w-32 duration-200'>
85+
<DarkModeButton />
86+
<div
87+
onClick={toggleDarkMode}
88+
className='cursor-pointer w-0 group-hover:w-24 duration-200 overflow-hidden whitespace-nowrap pl-1 h-auto'>
89+
{isDarkMode ? locale.MENU.DARK_MODE : locale.MENU.LIGHT_MODE}
90+
</div>
91+
</div>
6292

63-
{/* 主题切换按钮 */}
64-
<div className="text-sm flex items-center group-hover:w-32 transition-all duration-200">
65-
<i className="fa-solid fa-palette w-5" />
66-
<div className='w-0 group-hover:w-24 transition-all duration-200 overflow-hidden'>
67-
<label htmlFor="themeSelect" className="sr-only">选择主题:</label>
68-
<select id="themeSelect" value={currentTheme} onChange={onThemeSelectChange} name="themes" className='pl-1 bg-gray-50 dark:bg-black appearance-none outline-none dark:text-white uppercase cursor-pointer'>
69-
{THEMES?.map(t => {
70-
return <option key={t} value={t}>{t}</option>
71-
})}
72-
</select>
73-
</div>
74-
</div>
93+
{/* 翻译按钮 */}
94+
<div className='text-sm flex items-center group-hover:w-32 duration-200'>
95+
<i className='fa-solid fa-language w-5' />
96+
<div className='w-0 group-hover:w-24 duration-200 overflow-hidden'>
97+
<label htmlFor='langSelect' className='sr-only'>
98+
Language Select
99+
</label>
100+
<select
101+
id='langSelect'
102+
value={lang}
103+
onChange={onLangSelectChange}
104+
name='themes'
105+
className='pl-1 bg-gray-50 dark:bg-black appearance-none outline-none dark:text-white uppercase cursor-pointer'>
106+
{Object.keys(LANGS)?.map(t => {
107+
return (
108+
<option key={t} value={t}>
109+
{LANGS[t].LOCALE}
110+
</option>
111+
)
112+
})}
113+
</select>
75114
</div>
76-
</Draggable>
115+
</div>
116+
</div>
117+
</Draggable>
77118

78-
{/* 切换主题加载时的全屏遮罩 */}
79-
<div className={`${isLoading ? 'opacity-90 ' : 'opacity-0'}
119+
{/* 切换主题加载时的全屏遮罩 */}
120+
<div
121+
className={`${isLoading ? 'opacity-90 ' : 'opacity-0'}
80122
w-screen h-screen glassmorphism bg-black text-white shadow-text flex justify-center items-center
81-
transition-all fixed top-0 left-0 pointer-events-none duration-1000 z-50 shadow-inner`}>
82-
<i className='text-3xl mr-5 fas fa-spinner animate-spin' />
83-
</div>
123+
fixed top-0 left-0 pointer-events-none duration-1000 z-50 shadow-inner`}>
124+
<i className='text-3xl mr-5 fas fa-spinner animate-spin' />
125+
</div>
84126
</>
85127
)
86128
}

lib/config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ export const siteConfig = (key, defaultVal = null, extendConfig = {}) => {
5555
let siteInfo = null
5656

5757
if (global) {
58-
val = global.NOTION_CONFIG?.[key]
5958
siteInfo = global.siteInfo
59+
val = global.NOTION_CONFIG?.[key] || global.THEME_CONFIG?.[key]
6060
}
6161

6262
if (!val) {
@@ -122,7 +122,7 @@ export const convertVal = val => {
122122
}
123123

124124
// 配置值前可能有污染的空格
125-
if (!val.indexOf('[') > 0 || val.indexOf('{')) {
125+
if (val.indexOf('[') < 0 && val.indexOf('{') < 0) {
126126
return val
127127
}
128128

lib/db/getSiteData.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ export function getNavPages({ allPages }) {
347347
return (
348348
post &&
349349
post?.slug &&
350-
!post?.slug?.startsWith('http') &&
351350
post?.type === 'Post' &&
352351
post?.status === 'Published'
353352
)
@@ -512,6 +511,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
512511
adjustPageProperties(element, NOTION_CONFIG)
513512
})
514513

514+
// 站点基础信息
515515
const siteInfo = getSiteInfo({ collection, block, pageId })
516516

517517
// 文章计数
@@ -525,7 +525,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
525525
return (
526526
post &&
527527
post?.slug &&
528-
!post?.slug?.startsWith('http') &&
528+
// !post?.slug?.startsWith('http') &&
529529
(post?.status === 'Invisible' || post?.status === 'Published')
530530
)
531531
})

lib/global.js

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
THEMES,
3+
getThemeConfig,
34
initDarkMode,
45
saveDarkModeToLocalStorage
56
} from '@/themes/theme'
@@ -29,11 +30,14 @@ export function GlobalContextProvider(props) {
2930
tagOptions,
3031
NOTION_CONFIG
3132
} = props
33+
3234
const [lang, updateLang] = useState(NOTION_CONFIG?.LANG || LANG) // 默认语言
3335
const [locale, updateLocale] = useState(
3436
generateLocaleDict(NOTION_CONFIG?.LANG || LANG)
3537
) // 默认语言
3638
const [theme, setTheme] = useState(NOTION_CONFIG?.THEME || THEME) // 默认博客主题
39+
const [THEME_CONFIG, SET_THEME_CONFIG] = useState(null) // 主题配置
40+
3741
const defaultDarkMode = NOTION_CONFIG?.APPEARANCE || APPEARANCE
3842
const [isDarkMode, updateDarkMode] = useState(defaultDarkMode === 'dark') // 默认深色模式
3943
const [onLoading, setOnLoading] = useState(false) // 抓取文章数据
@@ -54,6 +58,12 @@ export function GlobalContextProvider(props) {
5458
return newTheme
5559
}
5660

61+
// 抓取主题配置
62+
const updateThemeConfig = async theme => {
63+
const config = await getThemeConfig(theme)
64+
SET_THEME_CONFIG(config)
65+
}
66+
5767
// 切换深色模式
5868
const toggleDarkMode = () => {
5969
const newStatus = !isDarkMode
@@ -99,6 +109,9 @@ export function GlobalContextProvider(props) {
99109
setOnLoading(false)
100110
}
101111

112+
const currentTheme = router?.query?.theme || theme
113+
updateThemeConfig(currentTheme)
114+
102115
router.events.on('routeChangeStart', handleStart)
103116
router.events.on('routeChangeError', handleStop)
104117
router.events.on('routeChangeComplete', handleStop)
@@ -114,6 +127,7 @@ export function GlobalContextProvider(props) {
114127
value={{
115128
fullWidth,
116129
NOTION_CONFIG,
130+
THEME_CONFIG,
117131
toggleDarkMode,
118132
onLoading,
119133
setOnLoading,

lib/lang/en-US.js

+4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ export default {
1414
INDEX: 'Home',
1515
RSS: 'RSS',
1616
SEARCH: 'Search',
17+
NAVIGATOR: 'NAV',
1718
ABOUT: 'About',
1819
MAIL: 'E-Mail',
1920
ARCHIVE: 'Archive'
2021
},
2122
COMMON: {
23+
THEME: 'Theme',
24+
ARTICLE_LIST: 'Article List',
25+
RECOMMEND_POSTS: 'Recommend Posts',
2226
MORE: 'More',
2327
NO_MORE: 'No More',
2428
LATEST_POSTS: 'Latest posts',

lib/lang/zh-CN.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export default {
2020
ARCHIVE: '归档'
2121
},
2222
COMMON: {
23+
THEME: 'Theme',
24+
ARTICLE_LIST: '文章列表',
25+
RECOMMEND_POSTS: '推荐文章',
2326
MORE: '更多',
2427
NO_MORE: '没有更多了',
2528
LATEST_POSTS: '最新发布',
@@ -63,7 +66,7 @@ export default {
6366
MINUTE: '分钟',
6467
WORD_COUNT: '字数',
6568
READ_TIME: '阅读时长',
66-
NEXT_POST:'下一篇'
69+
NEXT_POST: '下一篇'
6770
},
6871
PAGINATION: {
6972
PREV: '上页',

0 commit comments

Comments
 (0)