diff --git a/.env.local b/.env.local index 7843e719..bc05b1ef 100644 --- a/.env.local +++ b/.env.local @@ -1,2 +1,2 @@ # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=3.9.4 +NEXT_PUBLIC_VERSION=3.9.5 diff --git a/blog.config.js b/blog.config.js index fe3e8619..bcc9b741 100644 --- a/blog.config.js +++ b/blog.config.js @@ -22,7 +22,8 @@ const BLOG = { CONTACT_TELEGRAM: 'https://t.me/tangly_1024', // 你的telegram 地址 例如 https://t.me/tangly_1024 CONTACT_LINKEDIN: '', // 你的linkedIn 首页 - // 网站默认使用PingFangSC及NotoSansSC, + // 网站默认使用PingFangSC及NotoSansSC + FONT_STYLE: 'font-serif', // ['font-serif','font-sans'] 两种可选,分别是衬线和无衬线: 参考 https://www.jianshu.com/p/55e410bd2115 // 如需自定义字体,请将CUSTOM_FONT改为 true,并将CUSTOM_FONT_URL改为你的字体CSS地址,同时在CUSTOM_FONT_SANS与CUSTOM_FONT_SERIF中指定你的font-family CUSTOM_FONT: process.env.NEXT_PUBLIC_CUSTOM_FONT || false, // 是否使用自定义字体 // 自定义字体示例: 请先将 CUSTOM_FONT 改为 true, 并将 CUSTOM_FONT_URL 改为你的字体CSS地址,同时在 CUSTOM_FONT_SANS 与 CUSTOM_FONT_SERIF 中指定你的 fontfamily diff --git a/components/DebugPanel.js b/components/DebugPanel.js index 50add94a..fefc7c2b 100644 --- a/components/DebugPanel.js +++ b/components/DebugPanel.js @@ -1,6 +1,6 @@ import BLOG from '@/blog.config' import * as ThemeMap from '@/themes' -import { useState } from 'react' +import { useEffect, useState } from 'react' import Select from './Select' import { ALL_THEME } from '@/themes' import { useGlobal } from '@/lib/global' @@ -8,20 +8,39 @@ import { useGlobal } from '@/lib/global' * * @returns 调试面板 */ -export function DebugPanel () { +export function DebugPanel() { const [show, setShow] = useState(false) - const { theme, changeTheme, switchTheme } = useGlobal() + const { theme, changeTheme, switchTheme, locale } = useGlobal() + const [siteConfig, updateSiteConfig] = useState({}) + const [themeConfig, updateThemeConfig] = useState({}) + const [debugTheme, updateDebugTheme] = useState(BLOG.THEME) - const themeOptions = [] - ALL_THEME.forEach(t => { - themeOptions.push({ value: t, text: t }) - }) + // 主题下拉框 + const themeOptions = ALL_THEME.map(t => ({ value: t, text: t })) - function toggleShow () { + useEffect(() => { + changeTheme(BLOG.THEME) + updateSiteConfig(Object.assign({}, BLOG)) + updateThemeConfig(Object.assign({}, ThemeMap[BLOG.THEME].THEME_CONFIG)) + }, []) + + function toggleShow() { setShow(!show) } - function filterResult (text) { + function handleChangeDebugTheme() { + const newTheme = switchTheme() + updateThemeConfig(Object.assign({}, ThemeMap[newTheme].THEME_CONFIG)) + updateDebugTheme(newTheme) + } + + function handleUpdateDebugTheme(e) { + changeTheme(e) + updateThemeConfig(Object.assign({}, ThemeMap[theme].THEME_CONFIG)) + updateDebugTheme(e) + } + + function filterResult(text) { switch (text) { case 'true': return true @@ -34,76 +53,72 @@ export function DebugPanel () { } return ( - <> - {/* 调试按钮 */} -
-
- {show - ? ( -  关闭调试 - ) - : ( -  打开调试 - )} -
-
- -
-
- +
+ +
+
+ +
+
+
+ 主题配置{`config_${debugTheme}.js`}: +
+
+ {Object.keys(themeConfig).map(k => ( +
+ + {k} + + + {filterResult(themeConfig[k] + '')} + +
+ ))} +
+
+
+ 站点配置[blog.config.js] +
+
+ {siteConfig && Object.keys(siteConfig).map(k => ( +
+ + {k} + + + {filterResult(siteConfig[k] + '')} + +
+ ))} +
+
+ +
+ ) } diff --git a/lib/global.js b/lib/global.js index 6dd44e93..158f8ac6 100644 --- a/lib/global.js +++ b/lib/global.js @@ -37,7 +37,9 @@ export function GlobalContextProvider({ children }) { function switchTheme() { const currentIndex = ALL_THEME.indexOf(theme) const newIndex = currentIndex < ALL_THEME.length - 1 ? currentIndex + 1 : 0 - changeTheme(ALL_THEME[newIndex]) + const newTheme = ALL_THEME[newIndex] + changeTheme(newTheme) + return newTheme } function changeTheme(theme) { diff --git a/lib/lang/en-US.js b/lib/lang/en-US.js index 464a79d7..b5438cde 100644 --- a/lib/lang/en-US.js +++ b/lib/lang/en-US.js @@ -35,7 +35,10 @@ export default { SUBMIT: 'Submit', POST_TIME: 'Post on', LAST_EDITED_TIME: 'Last edited', - RECENT_COMMENTS: 'Recent Comments' + RECENT_COMMENTS: 'Recent Comments', + DEBUG_OPEN: 'Debug', + DEBUG_CLOSE: 'Close', + THEME_SWITCH: 'Theme Switch' }, PAGINATION: { PREV: 'Prev', diff --git a/lib/lang/zh-CN.js b/lib/lang/zh-CN.js index 43bb26c6..1ba84f91 100644 --- a/lib/lang/zh-CN.js +++ b/lib/lang/zh-CN.js @@ -37,7 +37,10 @@ export default { SUBMIT: '提交', POST_TIME: '发布于', LAST_EDITED_TIME: '最后更新', - RECENT_COMMENTS: '最新评论' + RECENT_COMMENTS: '最新评论', + DEBUG_OPEN: '开启调试', + DEBUG_CLOSE: '关闭调试', + THEME_SWITCH: '切换主题' }, PAGINATION: { PREV: '上一页', diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js index bf692fa2..fb655b33 100644 --- a/lib/notion/getNotionData.js +++ b/lib/notion/getNotionData.js @@ -236,8 +236,8 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) { }) } - const categoryOptions = getAllCategories({ allPages, categoryOptions: getCategoryOptions(schema), sliceCount: BLOG.PREVIEW_CATEGORY_COUNT }) - const tagOptions = getAllTags({ allPages, sliceCount: BLOG.PREVIEW_TAG_COUNT, tagOptions: getTagOptions(schema) }) + const categoryOptions = getAllCategories({ allPages, categoryOptions: getCategoryOptions(schema) }) + const tagOptions = getAllTags({ allPages, tagOptions: getTagOptions(schema) }) const siteInfo = getBlogInfo({ collection, block }) const customNav = getCustomNav({ allPages: collectionData.filter(post => post.type === 'Page' && post.status === 'Published') }) const latestPosts = getLatestPosts({ allPages, from, latestPostCount: 5 }) diff --git a/package.json b/package.json index 1393f6b7..d93964d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "notion-next", - "version": "3.9.4", + "version": "3.9.5", "homepage": "https://github.com/tangly1024/NotionNext.git", "license": "MIT", "repository": { diff --git a/pages/_document.js b/pages/_document.js index c24fa5c9..509230ca 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -17,7 +17,7 @@ class MyDocument extends Document { - +
diff --git a/pages/search/index.js b/pages/search/index.js index e8f51d32..fc20c5fd 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -19,7 +19,7 @@ const Search = props => { return searchContent.toLowerCase().includes(searchKey.toLowerCase()) }) } else { - filteredPosts = posts + filteredPosts = [] } const { locale } = useGlobal() diff --git a/themes/example/components/ExampleRecentComments.js b/themes/example/components/ExampleRecentComments.js index 42c8805e..b1555c1d 100644 --- a/themes/example/components/ExampleRecentComments.js +++ b/themes/example/components/ExampleRecentComments.js @@ -29,7 +29,7 @@ const ExampleRecentComments = (props) => {
--{comment.nick}
)} - ; + } export default ExampleRecentComments diff --git a/themes/fukasawa/components/GroupMenu.js b/themes/fukasawa/components/GroupMenu.js index afaec0e2..dc6e5fac 100644 --- a/themes/fukasawa/components/GroupMenu.js +++ b/themes/fukasawa/components/GroupMenu.js @@ -39,13 +39,13 @@ function GroupMenu ({ customNav }) { {link.slot} - ); + ) } else { return null } })} - ); + ) } export default GroupMenu diff --git a/themes/hexo/LayoutBase.js b/themes/hexo/LayoutBase.js index 59639a66..43086104 100644 --- a/themes/hexo/LayoutBase.js +++ b/themes/hexo/LayoutBase.js @@ -71,7 +71,7 @@ const LayoutBase = props => { id="container-inner" className={(BLOG.LAYOUT_SIDEBAR_REVERSE ? 'flex-row-reverse' : '') + ' pt-14 w-full mx-auto lg:flex lg:space-x-4 justify-center relative z-10'} > -
+
{onLoading ? : children}
diff --git a/themes/medium/LayoutBase.js b/themes/medium/LayoutBase.js index 477594c6..758cd806 100644 --- a/themes/medium/LayoutBase.js +++ b/themes/medium/LayoutBase.js @@ -42,10 +42,13 @@ const LayoutBase = props => { {slotTop} {children}
+ + {/* 底部 */} +