From b005a3209eb57af215b809ac075a43af35e4b90f Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 3 Mar 2022 20:30:48 +0800 Subject: [PATCH 01/19] =?UTF-8?q?=E5=8A=A8=E6=80=81Theme=20=E5=88=9D?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 3 ++- lib/global.js | 4 +++- pages/index.js | 5 ++++- themes/index.js | 18 +++++++++++++----- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/blog.config.js b/blog.config.js index 511376d0..91996bca 100644 --- a/blog.config.js +++ b/blog.config.js @@ -9,6 +9,7 @@ const BLOG = { 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 + 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 @@ -43,7 +44,7 @@ const BLOG = { COMMENT_UTTERRANCES_REPO: process.env.NEXT_PUBLIC_COMMENT_UTTERRANCES_REPO || '', // 你的代码仓库名, 例如我是 'tangly1024/NotionNext'; 更多文档参考 https://utteranc.es/ // gitalk评论插件 更多参考 https://gitalk.github.io/ - COMMENT_GITALK_REPO: process.env.NEXT_PUBLIC_COMMENT_GITALK_REPO || '', // 你的Github仓库名,例如 'NotionNext' + COMMENT_GITALK_REPO: process.env.NEXT_PUBLIC_COMMENT_GITALK_REPO || '', // 你的Github仓库名,例如 'NotionNext' COMMENT_GITALK_OWNER: process.env.NEXT_PUBLIC_COMMENT_GITALK_OWNER || '', // 你的用户名 e.g tangly1024 COMMENT_GITALK_ADMIN: process.env.NEXT_PUBLIC_COMMENT_GITALK_ADMIN || '', // 管理员用户名、一般是自己 e.g 'tangly1024' COMMENT_GITALK_CLIENT_ID: process.env.NEXT_PUBLIC_COMMENT_GITALK_CLIENT_ID || '', // e.g 20位ID , 在gitalk后台获取 diff --git a/lib/global.js b/lib/global.js index 08628942..7a2acb84 100644 --- a/lib/global.js +++ b/lib/global.js @@ -2,6 +2,7 @@ import lang from './lang' import { useContext, createContext, useState } from 'react' import Router from 'next/router' import { initDarkMode } from './theme' +import BLOG from '@/blog.config' const GlobalContext = createContext() let hasInit = false @@ -15,6 +16,7 @@ export function GlobalContextProvider ({ children }) { const [locale, updateLocale] = useState(generateLocaleDict('en-US')) const [isDarkMode, updateDarkMode] = useState(false) const [onLoading, changeLoadingState] = useState(false) + const [theme, setTheme] = useState(BLOG.THEME) Router.events.on('routeChangeStart', (...args) => { changeLoadingState(true) }) @@ -33,7 +35,7 @@ export function GlobalContextProvider ({ children }) { }, 100) return ( - + {children} ) diff --git a/pages/index.js b/pages/index.js index 599b3cf9..b97fad52 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,9 +1,12 @@ import BLOG from '@/blog.config' import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import { LayoutIndex, THEME_CONFIG } from '@/themes' +import { LayoutIndex, THEME_CONFIG, ThemeMap } from '@/themes' +import { useGlobal } from '@/lib/global' const Index = (props) => { + const { theme } = useGlobal() + console.log('模板', ThemeMap[theme].LayoutIndex) return } diff --git a/themes/index.js b/themes/index.js index 5acc65dd..0a55c5a0 100644 --- a/themes/index.js +++ b/themes/index.js @@ -2,8 +2,16 @@ * 修改 from 后面的路径,实现主题切换 */ -// export * from './Empty' // 空主题 -// export * from './NEXT' -// export * from './Fukasawa' -export * from './Hexo' -// export * from './Medium' +import * as Next from './Next' +import * as Empty from './Empty' +import * as Fukasawa from './Fukasawa' +import * as Hexo from './Hexo' +import * as Medium from './Medium' +export * from './Medium' +export const ThemeMap = { + Next, + Empty, + Fukasawa, + Hexo, + Medium +} From eb251d95142bf20fc5ab62119a366af444347385 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 3 Mar 2022 21:28:08 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E5=8A=A8=E6=80=81=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 5 +++-- lib/global.js | 5 ++++- pages/404.js | 6 ++++-- pages/[slug].js | 7 ++++--- pages/archive/index.js | 11 ++++++----- pages/article/[slug].js | 7 ++++--- pages/category/[category].js | 5 +++-- pages/category/index.js | 5 +++-- pages/index.js | 8 +++----- pages/page/[page].js | 11 +++++------ pages/search/[keyword].js | 25 +++++++++++++------------ pages/search/index.js | 6 ++++-- pages/tag/[tag].js | 5 +++-- pages/tag/index.js | 5 +++-- themes/index.js | 6 +++--- 15 files changed, 65 insertions(+), 52 deletions(-) diff --git a/blog.config.js b/blog.config.js index 91996bca..c06a9f26 100644 --- a/blog.config.js +++ b/blog.config.js @@ -8,12 +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_BUTTON: true, // 是否显示调试按钮,可以用来调试不同的主题和样式配置 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 @@ -21,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/lib/global.js b/lib/global.js index 7a2acb84..432a423f 100644 --- a/lib/global.js +++ b/lib/global.js @@ -3,6 +3,7 @@ import { useContext, createContext, useState } from 'react' import Router from 'next/router' import { initDarkMode } from './theme' import BLOG from '@/blog.config' +import { ThemeMap } from '@/themes' const GlobalContext = createContext() let hasInit = false @@ -17,6 +18,8 @@ export function GlobalContextProvider ({ children }) { const [isDarkMode, updateDarkMode] = useState(false) const [onLoading, changeLoadingState] = useState(false) const [theme, setTheme] = useState(BLOG.THEME) + const ThemeComponents = ThemeMap[theme] + Router.events.on('routeChangeStart', (...args) => { changeLoadingState(true) }) @@ -35,7 +38,7 @@ export function GlobalContextProvider ({ children }) { }, 100) return ( - + {children} ) diff --git a/pages/404.js b/pages/404.js index 64cc2dc7..b14f859b 100644 --- a/pages/404.js +++ b/pages/404.js @@ -1,4 +1,4 @@ -import { Layout404 } from '@/themes' +import { useGlobal } from '@/lib/global' /** * 自定义404界面 @@ -7,5 +7,7 @@ import { Layout404 } from '@/themes' */ export default function Custom404 (props) { - return + const { ThemeComponents } = useGlobal() + + return } diff --git a/pages/[slug].js b/pages/[slug].js index 4d1a13d9..eda1bc51 100644 --- a/pages/[slug].js +++ b/pages/[slug].js @@ -1,8 +1,8 @@ import BLOG from '@/blog.config' import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import { LayoutSlug } from '@/themes' -import Custom404 from '@/pages/404' +import { useGlobal } from '@/lib/global' +import Custom404 from './404' /** * 根据notion的slug访问页面,针对类型为Page的页面 @@ -10,10 +10,11 @@ import Custom404 from '@/pages/404' * @returns */ const Slug = (props) => { + const { ThemeComponents } = useGlobal() if (!props.post) { return } - return + return } export async function getStaticPaths () { diff --git a/pages/archive/index.js b/pages/archive/index.js index 4dffb49d..6d974951 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -1,6 +1,11 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import React from 'react' -import { LayoutArchive } from '@/themes' +import { useGlobal } from '@/lib/global' + +const ArchiveIndex = (props) => { + const { ThemeComponents } = useGlobal() + return +} export async function getStaticProps () { const { allPosts, categories, tags, postCount, customNav } = @@ -18,8 +23,4 @@ export async function getStaticProps () { } } -const ArchiveIndex = (props) => { - return -} - export default ArchiveIndex diff --git a/pages/article/[slug].js b/pages/article/[slug].js index d79e0cc7..29a03539 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -1,8 +1,8 @@ import BLOG from '@/blog.config' import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import { LayoutSlug } from '@/themes' -import Custom404 from '@/pages/404' +import { useGlobal } from '@/lib/global' +import Custom404 from '../404' /** * 根据notion的slug访问页面 @@ -10,10 +10,11 @@ import Custom404 from '@/pages/404' * @returns */ const Slug = (props) => { + const { ThemeComponents } = useGlobal() if (!props.post) { return } - return + return } export async function getStaticPaths () { diff --git a/pages/category/[category].js b/pages/category/[category].js index 681a23c6..3362d419 100644 --- a/pages/category/[category].js +++ b/pages/category/[category].js @@ -1,9 +1,10 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import React from 'react' -import { LayoutCategory } from '@/themes' +import { useGlobal } from '@/lib/global' export default function Category (props) { - return + const { ThemeComponents } = useGlobal() + return } export async function getStaticProps ({ params }) { diff --git a/pages/category/index.js b/pages/category/index.js index 7361a706..22232a7d 100644 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -1,9 +1,10 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import React from 'react' -import { LayoutCategoryIndex } from '@/themes' +import { useGlobal } from '@/lib/global' export default function Category (props) { - return + const { ThemeComponents } = useGlobal() + return } export async function getStaticProps () { diff --git a/pages/index.js b/pages/index.js index b97fad52..5cebee4c 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,13 +1,11 @@ import BLOG from '@/blog.config' import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import { LayoutIndex, THEME_CONFIG, ThemeMap } from '@/themes' import { useGlobal } from '@/lib/global' const Index = (props) => { - const { theme } = useGlobal() - console.log('模板', ThemeMap[theme].LayoutIndex) - return + const { ThemeComponents } = useGlobal() + return } export async function getStaticProps () { @@ -29,7 +27,7 @@ export async function getStaticProps () { BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page ) - if (THEME_CONFIG.POST_LIST_PREVIEW || BLOG.POST_LIST_PREVIEW) { + if (BLOG.POST_LIST_PREVIEW) { for (const i in postsToShow) { const post = postsToShow[i] const blockMap = await getPostBlocks(post.id, 'slug', BLOG.POST_PREVIEW_LINES) diff --git a/pages/page/[page].js b/pages/page/[page].js index 211a2f92..6a07589c 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -1,14 +1,14 @@ import BLOG from '@/blog.config' import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import { LayoutPage, THEME_CONFIG } from '@/themes' -import Custom404 from '@/pages/404' +import { useGlobal } from '@/lib/global' const Page = (props) => { + const { ThemeComponents } = useGlobal() if (!props?.meta) { - return + return } - return + return } export async function getStaticPaths () { @@ -43,8 +43,7 @@ export async function getStaticProps ({ params: { page } }) { BLOG.POSTS_PER_PAGE * (page - 1), BLOG.POSTS_PER_PAGE * page ) - // 加载预览 - if (THEME_CONFIG.POST_LIST_PREVIEW || BLOG.POST_LIST_PREVIEW) { + if (BLOG.POST_LIST_PREVIEW) { for (const i in postsToShow) { const post = postsToShow[i] const blockMap = await getPostBlocks(post.id, 'slug', BLOG.POST_PREVIEW_LINES) diff --git a/pages/search/[keyword].js b/pages/search/[keyword].js index 4bc6166e..109768db 100644 --- a/pages/search/[keyword].js +++ b/pages/search/[keyword].js @@ -1,9 +1,21 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import { LayoutSearch } from '@/themes' import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import { getDataFromCache } from '@/lib/cache/cache_manager' +const Index = (props) => { + const { keyword } = props + const { locale } = useGlobal() + const meta = { + title: `${keyword || ''} | ${locale.NAV.SEARCH} | ${BLOG.TITLE} `, + description: BLOG.DESCRIPTION, + type: 'website' + } + + const { ThemeComponents } = useGlobal() + return +} + /** * 服务端搜索 * @param {*} param0 @@ -33,17 +45,6 @@ export async function getServerSideProps ({ params: { keyword } }) { } } -const Index = (props) => { - const { keyword } = props - const { locale } = useGlobal() - const meta = { - title: `${keyword || ''} | ${locale.NAV.SEARCH} | ${BLOG.TITLE} `, - description: BLOG.DESCRIPTION, - type: 'website' - } - return -} - /** * 将对象的指定字段拼接到字符串 * @param sourceTextArray diff --git a/pages/search/index.js b/pages/search/index.js index fb1ffc89..f0d266f3 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -1,5 +1,4 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import { LayoutSearch } from '@/themes' import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import { useRouter } from 'next/router' @@ -51,7 +50,10 @@ const Search = (props) => { description: BLOG.DESCRIPTION, type: 'website' } - return + + const { ThemeComponents } = useGlobal() + + return } function getSearchKey () { diff --git a/pages/tag/[tag].js b/pages/tag/[tag].js index 169352f6..90a5a9d2 100644 --- a/pages/tag/[tag].js +++ b/pages/tag/[tag].js @@ -1,8 +1,9 @@ +import { useGlobal } from '@/lib/global' import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import { LayoutTag } from '@/themes' const Tag = (props) => { - return + const { ThemeComponents } = useGlobal() + return } export async function getStaticProps ({ params }) { diff --git a/pages/tag/index.js b/pages/tag/index.js index cdf8a401..90d0b9ec 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -1,9 +1,10 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import React from 'react' -import { LayoutTagIndex } from '@/themes' +import { useGlobal } from '@/lib/global' const TagIndex = (props) => { - return + const { ThemeComponents } = useGlobal() + return } export async function getStaticProps () { diff --git a/themes/index.js b/themes/index.js index 0a55c5a0..84cd91f1 100644 --- a/themes/index.js +++ b/themes/index.js @@ -3,15 +3,15 @@ */ import * as Next from './Next' -import * as Empty from './Empty' import * as Fukasawa from './Fukasawa' import * as Hexo from './Hexo' import * as Medium from './Medium' +import * as Empty from './Empty' export * from './Medium' export const ThemeMap = { Next, - Empty, Fukasawa, Hexo, - Medium + Medium, + Empty } From 9dd1cb6eebf85c272b8518eb9503e763aa853203 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 3 Mar 2022 21:28:16 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/DebugButton.js | 50 +++++++++++++++++++++++++++++++++++++++ pages/_app.js | 2 ++ 2 files changed, 52 insertions(+) create mode 100644 components/DebugButton.js diff --git a/components/DebugButton.js b/components/DebugButton.js new file mode 100644 index 00000000..064d1991 --- /dev/null +++ b/components/DebugButton.js @@ -0,0 +1,50 @@ +import { useGlobal } from '@/lib/global' +import { ThemeMap } from '@/themes' +import { useState } from 'react' + +/** + * + * @returns 调试面板 + */ +export function DebugButton () { + const [show, setShow] = useState(false) + const GlobalConfig = useGlobal() + const { theme, setTheme } = GlobalConfig + const allThemes = Object.keys(ThemeMap) + function toggleShow () { + setShow(!show) + } + + /** + * 切换主题 + */ + function changeTheme () { + const currentIndex = allThemes.indexOf(theme) + const newIndex = currentIndex < allThemes.length - 1 ? currentIndex + 1 : 0 + setTheme(allThemes[newIndex]) + } + + return <> +
+
+
当前主题:
+
{theme}
+
+
+
所有主题:
+
{allThemes.join(',')}
+
+
+
更换主题
+
+
+
所有配置:
+

{JSON.stringify(GlobalConfig)}

+
+
+ +
+
调试按钮
+
+ +} diff --git a/pages/_app.js b/pages/_app.js index e5b63150..0f0948ed 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -14,6 +14,7 @@ import 'prismjs/themes/prism-okaidia.css' import 'katex/dist/katex.min.css' import dynamic from 'next/dynamic' import { GlobalContextProvider } from '@/lib/global' +import { DebugButton } from '@/components/DebugButton' const Ackee = dynamic(() => import('@/components/Ackee'), { ssr: false }) const Gtag = dynamic(() => import('@/components/Gtag'), { ssr: false }) @@ -23,6 +24,7 @@ const GoogleAdsense = dynamic(() => import('@/components/GoogleAdsense'), { ssr: const MyApp = ({ Component, pageProps }) => { return ( + {BLOG.DEBUG_BUTTON && } {BLOG.ANALYTICS_ACKEE_TRACKER && } {BLOG.ANALYTICS_GOOGLE_ID && } {JSON.parse(BLOG.ANALYTICS_BUSUANZI_ENABLE) && } From 9336249a0a6ca9dbb80df3b5ea3fe4e0d201aa72 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 3 Mar 2022 21:29:54 +0800 Subject: [PATCH 04/19] build --- pages/page/[page].js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/page/[page].js b/pages/page/[page].js index 6a07589c..9d879940 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -2,11 +2,12 @@ import BLOG from '@/blog.config' import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' import { useGlobal } from '@/lib/global' +import Custom404 from '../404' const Page = (props) => { const { ThemeComponents } = useGlobal() if (!props?.meta) { - return + return } return } From e4ce0a567815427e103a22cee6c610a331ee19a8 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 3 Mar 2022 21:32:54 +0800 Subject: [PATCH 05/19] =?UTF-8?q?table=20z-index=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- styles/notion.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/styles/notion.css b/styles/notion.css index b8466a2a..d42d3b11 100644 --- a/styles/notion.css +++ b/styles/notion.css @@ -992,7 +992,7 @@ svg.notion-page-icon { .notion-board-header { display: flex; position: absolute; - z-index: 82; + z-index: 30; height: 44px; min-width: 100%; } @@ -1749,7 +1749,7 @@ pre[class*='language-'] { .notion-table-header { display: flex; position: absolute; - z-index: 82; + z-index:30; height: 33px; color: var(--fg-color-3); min-width: var(--notion-max-width); From 14beb27d0bf75529270383a0f5a916576fa62a80 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Thu, 3 Mar 2022 21:35:20 +0800 Subject: [PATCH 06/19] =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/DebugButton.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/DebugButton.js b/components/DebugButton.js index 064d1991..7d20558c 100644 --- a/components/DebugButton.js +++ b/components/DebugButton.js @@ -43,8 +43,8 @@ export function DebugButton () { -
-
调试按钮
+
+
调试按钮
} From d118526e12a47b410018ed999084bd2b488436e0 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 4 Mar 2022 17:14:10 +0800 Subject: [PATCH 07/19] =?UTF-8?q?=E6=A0=87=E9=A2=98=E5=8F=96=E6=B6=88Flex?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Hexo/components/BlogPostCard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/Hexo/components/BlogPostCard.js b/themes/Hexo/components/BlogPostCard.js index 3c75b9d9..71ba8ccd 100644 --- a/themes/Hexo/components/BlogPostCard.js +++ b/themes/Hexo/components/BlogPostCard.js @@ -14,7 +14,7 @@ const BlogPostCard = ({ post, showSummary }) => {
- + {post.title} From f2736cbee2531721068a6acd689f944fa0438518 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 8 Mar 2022 13:18:48 +0800 Subject: [PATCH 08/19] =?UTF-8?q?Hexo=20=E8=8F=9C=E5=8D=95=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/lang/en-US.js | 1 + lib/lang/zh-CN.js | 1 + themes/Hexo/components/InfoCard.js | 28 ++++++++++++++++++ themes/Hexo/components/MenuButtonGroup.js | 35 +++++++++-------------- themes/Hexo/components/SideRight.js | 29 ++----------------- themes/Hexo/config_hexo.js | 3 +- 6 files changed, 47 insertions(+), 50 deletions(-) create mode 100644 themes/Hexo/components/InfoCard.js diff --git a/lib/lang/en-US.js b/lib/lang/en-US.js index 928e7295..5e02c979 100644 --- a/lib/lang/en-US.js +++ b/lib/lang/en-US.js @@ -24,6 +24,7 @@ export default { AUTHOR: 'Author', URL: 'URL', POSTS: 'Posts', + ARTICLE: 'Article', VISITORS: 'Visitors', VIEWS: 'Views', COPYRIGHT_NOTICE: 'All articles in this blog, except for special statements, adopt BY-NC-SA agreement. Please indicate the source!', diff --git a/lib/lang/zh-CN.js b/lib/lang/zh-CN.js index 02e07cf0..915c1a9a 100644 --- a/lib/lang/zh-CN.js +++ b/lib/lang/zh-CN.js @@ -26,6 +26,7 @@ export default { URL: '链接', ANALYTICS: '统计', POSTS: '篇文章', + ARTICLE: '文章', VISITORS: '位访客', VIEWS: '次查看', COPYRIGHT_NOTICE: '本文采用 CC BY-NC-SA 4.0 许可协议,转载请注明出处。', diff --git a/themes/Hexo/components/InfoCard.js b/themes/Hexo/components/InfoCard.js new file mode 100644 index 00000000..28302d0d --- /dev/null +++ b/themes/Hexo/components/InfoCard.js @@ -0,0 +1,28 @@ +import BLOG from '@/blog.config' +import Image from 'next/image' +import { Router } from 'next/router' +import Card from './Card' +import SocialButton from './SocialButton' +import MenuButtonGroup from './MenuButtonGroup' +export function InfoCard (props) { + return +
{ + Router.push('/') + }} + > + {BLOG.AUTHOR} +
+
{BLOG.TITLE}
+ + +
+} diff --git a/themes/Hexo/components/MenuButtonGroup.js b/themes/Hexo/components/MenuButtonGroup.js index cf7af3cd..e0e6946c 100644 --- a/themes/Hexo/components/MenuButtonGroup.js +++ b/themes/Hexo/components/MenuButtonGroup.js @@ -1,37 +1,30 @@ import React from 'react' import Link from 'next/link' -import { useRouter } from 'next/router' import { useGlobal } from '@/lib/global' import CONFIG_HEXO from '../config_hexo' const MenuButtonGroup = (props) => { - const { postCount, customNav } = props + const { postCount, categories, tags } = props const { locale } = useGlobal() - const router = useRouter() - const archiveSlot =
{postCount}
+ const archiveSlot =
{postCount}
+ const categorySlot =
{categories?.length}
+ const tagSlot =
{tags?.length}
- let links = [ - { icon: 'fas fa-home', name: locale.NAV.INDEX, to: '/' || '/', show: true }, - { icon: 'fas fa-th', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG_HEXO.MENU_CATEGORY }, - { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG_HEXO.MENU_TAG }, - { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', slot: archiveSlot, show: CONFIG_HEXO.MENU_ARCHIVE }, - { icon: 'fas fa-user', name: locale.NAV.ABOUT, to: '/about', show: CONFIG_HEXO.MENU_ABOUT } + const links = [ + { name: locale.COMMON.ARTICLE, to: '/archive', slot: archiveSlot, show: CONFIG_HEXO.MENU_ARCHIVE }, + { name: locale.COMMON.CATEGORY, to: '/category', slot: categorySlot, show: CONFIG_HEXO.MENU_CATEGORY }, + { name: locale.COMMON.TAGS, to: '/tag', slot: tagSlot, show: CONFIG_HEXO.MENU_TAG } ] - if (customNav) { - links = links.concat(customNav) - } - return