diff --git a/blog.config.js b/blog.config.js index 83fb4061..90726a7e 100644 --- a/blog.config.js +++ b/blog.config.js @@ -8,11 +8,13 @@ const BLOG = { KEYWORDS: 'Notion, 博客', // 网站关键词 英文逗号隔开 NOTION_PAGE_ID: process.env.NOTION_PAGE_ID || '02ab3b8678004aa69e9e415905ef32a5', // Important page_id!!!Duplicate Template from https://www.notion.so/tanghh/02ab3b8678004aa69e9e415905ef32a5 NOTION_ACCESS_TOKEN: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public + DEBUG: process.env.NEXT_PUBLIC_DEBUG || false, // 是否显示调试按钮 + THEME: process.env.NEXT_PUBLIC_THEME || 'next', // 主题, 支持 ['Next','Hexo',"Fukasawa','Medium'] LANG: 'zh-CN', // e.g 'zh-CN','en-US' see /lib/lang.js for more. SINCE: 2021, // e.g if leave this empty, current year will be used. BEI_AN: process.env.NEXT_PUBLIC_BEI_AN || '', // 备案号 闽ICP备XXXXXXX - APPEARANCE: 'auto', // ['light', 'dark', 'auto'], + APPEARANCE: 'light', // ['light', 'dark', 'auto'], // light 日间模式 , dark夜间模式, auto根据时间和主题自动夜间模式 FONT: 'font-serif tracking-wider subpixel-antialiased', // 文章字体 ['font-sans', 'font-serif', 'font-mono'] @see https://www.tailwindcss.cn/docs/font-family FONT_AWESOME_PATH: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.4/css/all.min.css', // 图标库CDN ,国内推荐BootCDN,国外推荐 CloudFlare https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css BACKGROUND_LIGHT: '#eeeeee', // use hex value, don't forget '#' e.g #fffefc @@ -20,7 +22,7 @@ const BLOG = { PATH: '', // leave this empty unless you want to deploy in a folder POST_LIST_STYLE: 'page', // ['page','scroll] 文章列表样式:页码分页、单页滚动加载 - POST_LIST_PREVIEW: false, // 是否在列表加载文章预览, 会被各主题中的同名配置覆盖,例:/themes/NEXT/config_next.js + POST_LIST_PREVIEW: false, // 是否在列表加载文章预览 POST_PREVIEW_LINES: 12, // 预览博客行数 POSTS_PER_PAGE: 6, // post counts per page POSTS_SORT_BY: 'notion', // 排序方式 'date'按时间,'notion'由notion控制 diff --git a/components/DebugPanel.js b/components/DebugPanel.js new file mode 100644 index 00000000..40f82f54 --- /dev/null +++ b/components/DebugPanel.js @@ -0,0 +1,124 @@ +import BLOG from '@/blog.config' +import { useGlobal } from '@/lib/global' +import * as ThemeMap from '@/themes' +import { useState } from 'react' +import { useRouter } from 'next/router' +import Select from './Select' +import { ALL_THEME } from '@/lib/theme' +/** + * + * @returns 调试面板 + */ +export function DebugPanel () { + const [show, setShow] = useState(false) + const GlobalConfig = useGlobal() + const router = useRouter() + const { theme, setTheme } = GlobalConfig + const themeOptions = [] + ALL_THEME.forEach(t => { + themeOptions.push({ value: t, text: t }) + }) + + function toggleShow () { + setShow(!show) + } + + function switchTheme () { + const currentIndex = ALL_THEME.indexOf(theme) + const newIndex = currentIndex < ALL_THEME.length - 1 ? currentIndex + 1 : 0 + changeTheme(ALL_THEME[newIndex]) + } + /** + * 切换主题 + */ + function changeTheme (theme) { + router.query.theme = '' + setTheme(theme) + } + + function filterResult (text) { + switch (text) { + case 'true': + return true + case 'false': + return false + case '': + return '-' + } + return text + } + + return ( + <> + {/* 调试按钮 */} +
- {/* Notion文章主体 */}
-
+