From b1cc3d394a92e8f2dffc914ebdb4239560ea9f45 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 18 Feb 2022 11:24:52 +0800 Subject: [PATCH 01/42] =?UTF-8?q?Medium=20=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/index.js b/themes/index.js index e9b63872..d17405e5 100644 --- a/themes/index.js +++ b/themes/index.js @@ -3,7 +3,7 @@ */ // export * from './Empty' // 空主题 -export * from './NEXT' +// export * from './NEXT' // export * from './Fukasawa' // export * from './Hexo' -// export * from './Medium' +export * from './Medium' From 434f94e4ff2281525349b72c5a33b7825dd01527 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 18 Feb 2022 11:30:46 +0800 Subject: [PATCH 02/42] =?UTF-8?q?Medium=20=E4=B8=BB=E9=A2=98=20-=20?= =?UTF-8?q?=E6=A0=87=E9=A2=98=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Medium/LayoutBase.js | 2 +- themes/Medium/components/LogoBar.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/themes/Medium/LayoutBase.js b/themes/Medium/LayoutBase.js index b0519c52..cae89484 100644 --- a/themes/Medium/LayoutBase.js +++ b/themes/Medium/LayoutBase.js @@ -30,7 +30,7 @@ const LayoutBase = props => {
{/* 移动端顶部菜单 */} -
+
{slotTop} {children}
diff --git a/themes/Medium/components/LogoBar.js b/themes/Medium/components/LogoBar.js index c4fb5b1d..9a654956 100644 --- a/themes/Medium/components/LogoBar.js +++ b/themes/Medium/components/LogoBar.js @@ -2,13 +2,11 @@ import BLOG from '@/blog.config' import Link from 'next/link' export default function LogoBar () { - return
-
-
+ return
} From b4d160a6eb0ff8bf34521646a86928f3e9d9b461 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 28 Feb 2022 14:42:39 +0800 Subject: [PATCH 03/42] =?UTF-8?q?Medium=20=E4=BF=AE=E5=A4=8D=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=8F=92=E4=BB=B6=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Medium/components/PaginationSimple.js | 2 +- themes/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/Medium/components/PaginationSimple.js b/themes/Medium/components/PaginationSimple.js index 5f4698ac..fcf06ba2 100644 --- a/themes/Medium/components/PaginationSimple.js +++ b/themes/Medium/components/PaginationSimple.js @@ -14,7 +14,7 @@ const PaginationSimple = ({ page, totalPage }) => { const { locale } = useGlobal() const router = useRouter() const currentPage = +page - const showNext = currentPage <= totalPage + const showNext = currentPage < totalPage return (
Date: Thu, 3 Mar 2022 20:30:48 +0800 Subject: [PATCH 04/42] =?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 05/42] =?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 06/42] =?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 07/42] 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 08/42] =?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 09/42] =?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 e5cf41079c0eeedc7e6cc5f60eafd88462c08ddf Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 8 Mar 2022 11:14:18 +0800 Subject: [PATCH 10/42] Update index.js --- themes/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/index.js b/themes/index.js index 5acc65dd..e9b63872 100644 --- a/themes/index.js +++ b/themes/index.js @@ -3,7 +3,7 @@ */ // export * from './Empty' // 空主题 -// export * from './NEXT' +export * from './NEXT' // export * from './Fukasawa' -export * from './Hexo' +// export * from './Hexo' // export * from './Medium' From 270d05683041884275035cdad4a7ed97294a3599 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 8 Mar 2022 12:09:58 +0800 Subject: [PATCH 11/42] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/formatDate.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/formatDate.js b/lib/formatDate.js index 8be365fc..5674b170 100644 --- a/lib/formatDate.js +++ b/lib/formatDate.js @@ -5,6 +5,7 @@ * @returns {string} */ export default function formatDate (date, local) { + if (!date) return '' const d = new Date(date) const options = { year: 'numeric', month: 'short', day: 'numeric' } const res = d.toLocaleDateString(local, options) From 69422fff7f070f7c1ca7a43a601a581bbb3c93ba Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 8 Mar 2022 18:06:37 +0800 Subject: [PATCH 12/42] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 2 +- components/DebugButton.js | 2 +- lib/global.js | 3 ++- pages/index.js | 4 +++- themes/Empty/index.js | 35 ++++++++++++++++++++++++----------- themes/Fukasawa/index.js | 35 ++++++++++++++++++++++++----------- themes/Hexo/index.js | 35 ++++++++++++++++++++++++----------- themes/Medium/index.js | 35 ++++++++++++++++++++++++----------- themes/NEXT/index.js | 35 ++++++++++++++++++++++++----------- themes/index.js | 23 +++++++++++------------ 10 files changed, 138 insertions(+), 71 deletions(-) diff --git a/blog.config.js b/blog.config.js index c06a9f26..8cc40d7a 100644 --- a/blog.config.js +++ b/blog.config.js @@ -10,7 +10,7 @@ const BLOG = { 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'] + 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 diff --git a/components/DebugButton.js b/components/DebugButton.js index 7d20558c..a20c97b2 100644 --- a/components/DebugButton.js +++ b/components/DebugButton.js @@ -1,5 +1,5 @@ import { useGlobal } from '@/lib/global' -import { ThemeMap } from '@/themes' +import * as ThemeMap from '@/themes' import { useState } from 'react' /** diff --git a/lib/global.js b/lib/global.js index 432a423f..1e1fe572 100644 --- a/lib/global.js +++ b/lib/global.js @@ -3,7 +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' +import * as ThemeMap from '@/themes' const GlobalContext = createContext() let hasInit = false @@ -18,6 +18,7 @@ export function GlobalContextProvider ({ children }) { const [isDarkMode, updateDarkMode] = useState(false) const [onLoading, changeLoadingState] = useState(false) const [theme, setTheme] = useState(BLOG.THEME) + console.log('ThemeMap', ThemeMap) const ThemeComponents = ThemeMap[theme] Router.events.on('routeChangeStart', (...args) => { diff --git a/pages/index.js b/pages/index.js index 5cebee4c..601e6671 100644 --- a/pages/index.js +++ b/pages/index.js @@ -2,9 +2,11 @@ import BLOG from '@/blog.config' import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' import { useGlobal } from '@/lib/global' - const Index = (props) => { const { ThemeComponents } = useGlobal() + // return + console.log(ThemeComponents) + // return <> return } diff --git a/themes/Empty/index.js b/themes/Empty/index.js index 22fd5d15..95b0a6b2 100644 --- a/themes/Empty/index.js +++ b/themes/Empty/index.js @@ -1,12 +1,25 @@ import CONFIG_EMPTY from './config_empty' -export { CONFIG_EMPTY as THEME_CONFIG } -export { LayoutIndex } from './LayoutIndex' -export { LayoutSearch } from './LayoutSearch' -export { LayoutArchive } from './LayoutArchive' -export { LayoutSlug } from './LayoutSlug' -export { Layout404 } from './Layout404' -export { LayoutCategory } from './LayoutCategory' -export { LayoutCategoryIndex } from './LayoutCategoryIndex' -export { LayoutPage } from './LayoutPage' -export { LayoutTag } from './LayoutTag' -export { LayoutTagIndex } from './LayoutTagIndex' +import { LayoutIndex } from './LayoutIndex' +import { LayoutSearch } from './LayoutSearch' +import { LayoutArchive } from './LayoutArchive' +import { LayoutSlug } from './LayoutSlug' +import { Layout404 } from './Layout404' +import { LayoutCategory } from './LayoutCategory' +import { LayoutCategoryIndex } from './LayoutCategoryIndex' +import { LayoutPage } from './LayoutPage' +import { LayoutTag } from './LayoutTag' +import { LayoutTagIndex } from './LayoutTagIndex' + +export { + CONFIG_EMPTY as THEME_CONFIG, + LayoutIndex, + LayoutSearch, + LayoutArchive, + LayoutSlug, + Layout404, + LayoutCategory, + LayoutCategoryIndex, + LayoutPage, + LayoutTag, + LayoutTagIndex +} diff --git a/themes/Fukasawa/index.js b/themes/Fukasawa/index.js index e9e4db72..58968469 100644 --- a/themes/Fukasawa/index.js +++ b/themes/Fukasawa/index.js @@ -1,12 +1,25 @@ import CONFIG_FUKA from './config_fuka' -export { CONFIG_FUKA as THEME_CONFIG } -export { LayoutIndex } from './LayoutIndex' -export { LayoutSearch } from './LayoutSearch' -export { LayoutArchive } from './LayoutArchive' -export { LayoutSlug } from './LayoutSlug' -export { Layout404 } from './Layout404' -export { LayoutCategory } from './LayoutCategory' -export { LayoutCategoryIndex } from './LayoutCategoryIndex' -export { LayoutPage } from './LayoutPage' -export { LayoutTag } from './LayoutTag' -export { LayoutTagIndex } from './LayoutTagIndex' +import { LayoutIndex } from './LayoutIndex' +import { LayoutSearch } from './LayoutSearch' +import { LayoutArchive } from './LayoutArchive' +import { LayoutSlug } from './LayoutSlug' +import { Layout404 } from './Layout404' +import { LayoutCategory } from './LayoutCategory' +import { LayoutCategoryIndex } from './LayoutCategoryIndex' +import { LayoutPage } from './LayoutPage' +import { LayoutTag } from './LayoutTag' +import { LayoutTagIndex } from './LayoutTagIndex' + +export { + CONFIG_FUKA as THEME_CONFIG, + LayoutIndex, + LayoutSearch, + LayoutArchive, + LayoutSlug, + Layout404, + LayoutCategory, + LayoutCategoryIndex, + LayoutPage, + LayoutTag, + LayoutTagIndex +} diff --git a/themes/Hexo/index.js b/themes/Hexo/index.js index 15af8476..8528d5da 100644 --- a/themes/Hexo/index.js +++ b/themes/Hexo/index.js @@ -1,12 +1,25 @@ import CONFIG_HEXO from './config_hexo' -export { LayoutIndex } from './LayoutIndex' -export { LayoutSearch } from './LayoutSearch' -export { LayoutArchive } from './LayoutArchive' -export { LayoutSlug } from './LayoutSlug' -export { Layout404 } from './Layout404' -export { LayoutCategory } from './LayoutCategory' -export { LayoutCategoryIndex } from './LayoutCategoryIndex' -export { LayoutPage } from './LayoutPage' -export { LayoutTag } from './LayoutTag' -export { LayoutTagIndex } from './LayoutTagIndex' -export { CONFIG_HEXO as THEME_CONFIG } +import { LayoutIndex } from './LayoutIndex' +import { LayoutSearch } from './LayoutSearch' +import { LayoutArchive } from './LayoutArchive' +import { LayoutSlug } from './LayoutSlug' +import { Layout404 } from './Layout404' +import { LayoutCategory } from './LayoutCategory' +import { LayoutCategoryIndex } from './LayoutCategoryIndex' +import { LayoutPage } from './LayoutPage' +import { LayoutTag } from './LayoutTag' +import { LayoutTagIndex } from './LayoutTagIndex' + +export { + CONFIG_HEXO as THEME_CONFIG, + LayoutIndex, + LayoutSearch, + LayoutArchive, + LayoutSlug, + Layout404, + LayoutCategory, + LayoutCategoryIndex, + LayoutPage, + LayoutTag, + LayoutTagIndex +} diff --git a/themes/Medium/index.js b/themes/Medium/index.js index 5bcc655c..81961c58 100644 --- a/themes/Medium/index.js +++ b/themes/Medium/index.js @@ -1,12 +1,25 @@ import CONFIG_MEDIUM from './config_medium' -export { CONFIG_MEDIUM as THEME_CONFIG } -export { LayoutIndex } from './LayoutIndex' -export { LayoutSearch } from './LayoutSearch' -export { LayoutArchive } from './LayoutArchive' -export { LayoutSlug } from './LayoutSlug' -export { Layout404 } from './Layout404' -export { LayoutCategory } from './LayoutCategory' -export { LayoutCategoryIndex } from './LayoutCategoryIndex' -export { LayoutPage } from './LayoutPage' -export { LayoutTag } from './LayoutTag' -export { LayoutTagIndex } from './LayoutTagIndex' +import { LayoutIndex } from './LayoutIndex' +import { LayoutSearch } from './LayoutSearch' +import { LayoutArchive } from './LayoutArchive' +import { LayoutSlug } from './LayoutSlug' +import { Layout404 } from './Layout404' +import { LayoutCategory } from './LayoutCategory' +import { LayoutCategoryIndex } from './LayoutCategoryIndex' +import { LayoutPage } from './LayoutPage' +import { LayoutTag } from './LayoutTag' +import { LayoutTagIndex } from './LayoutTagIndex' + +export { + CONFIG_MEDIUM as THEME_CONFIG, + LayoutIndex, + LayoutSearch, + LayoutArchive, + LayoutSlug, + Layout404, + LayoutCategory, + LayoutCategoryIndex, + LayoutPage, + LayoutTag, + LayoutTagIndex +} diff --git a/themes/NEXT/index.js b/themes/NEXT/index.js index 76179137..45286719 100644 --- a/themes/NEXT/index.js +++ b/themes/NEXT/index.js @@ -1,12 +1,25 @@ import CONFIG_NEXT from './config_next' -export { CONFIG_NEXT as THEME_CONFIG } -export { LayoutIndex } from './LayoutIndex' -export { LayoutSearch } from './LayoutSearch' -export { LayoutArchive } from './LayoutArchive' -export { LayoutSlug } from './LayoutSlug' -export { Layout404 } from './Layout404' -export { LayoutCategory } from './LayoutCategory' -export { LayoutCategoryIndex } from './LayoutCategoryIndex' -export { LayoutPage } from './LayoutPage' -export { LayoutTag } from './LayoutTag' -export { LayoutTagIndex } from './LayoutTagIndex' +import { LayoutIndex } from './LayoutIndex' +import { LayoutSearch } from './LayoutSearch' +import { LayoutArchive } from './LayoutArchive' +import { LayoutSlug } from './LayoutSlug' +import { Layout404 } from './Layout404' +import { LayoutCategory } from './LayoutCategory' +import { LayoutCategoryIndex } from './LayoutCategoryIndex' +import { LayoutPage } from './LayoutPage' +import { LayoutTag } from './LayoutTag' +import { LayoutTagIndex } from './LayoutTagIndex' + +export { + CONFIG_NEXT as THEME_CONFIG, + LayoutIndex, + LayoutSearch, + LayoutArchive, + LayoutSlug, + Layout404, + LayoutCategory, + LayoutCategoryIndex, + LayoutPage, + LayoutTag, + LayoutTagIndex +} diff --git a/themes/index.js b/themes/index.js index 84cd91f1..d47d2a42 100644 --- a/themes/index.js +++ b/themes/index.js @@ -2,16 +2,15 @@ * 修改 from 后面的路径,实现主题切换 */ -import * as Next from './Next' -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, - Fukasawa, - Hexo, - Medium, - Empty +import * as next from './next' +import * as fukasawa from './fukasawa' +import * as hexo from './hexo' +import * as medium from './medium' +import * as empty from './empty' +export { + next, + fukasawa, + hexo, + medium, + empty } From 24007eed1aae0f1c503bf806d000e7ebb515d73c Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 9 Mar 2022 17:28:47 +0800 Subject: [PATCH 13/42] =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E5=88=9D=E7=89=88=E6=9C=AC=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jsconfig.json | 1 - lib/global.js | 5 +-- pages/404.js | 5 ++- pages/[slug].js | 4 +- pages/archive/index.js | 4 +- pages/article/[slug].js | 4 +- pages/category/[category].js | 4 +- pages/category/index.js | 4 +- pages/index.js | 7 ++-- pages/page/[page].js | 4 +- pages/search/[keyword].js | 4 +- pages/search/index.js | 47 ++++++++++------------- pages/tag/[tag].js | 4 +- pages/tag/index.js | 4 +- themes/Empty/LayoutPage.js | 2 +- themes/Medium/components/BottomMenuBar.js | 2 +- themes/Medium/components/TopNavBar.js | 2 +- 17 files changed, 58 insertions(+), 49 deletions(-) diff --git a/jsconfig.json b/jsconfig.json index 9802ad57..f6f71d10 100644 --- a/jsconfig.json +++ b/jsconfig.json @@ -5,7 +5,6 @@ "@/*": ["./*"], "@/components/*": ["components/*"], "@/data/*": ["data/*"], - "@/layouts/*": ["theme/*"], "@/lib/*": ["lib/*"], "@/styles/*": ["styles/*"] } diff --git a/lib/global.js b/lib/global.js index 1e1fe572..28b5b292 100644 --- a/lib/global.js +++ b/lib/global.js @@ -3,7 +3,6 @@ import { useContext, createContext, useState } from 'react' import Router from 'next/router' import { initDarkMode } from './theme' import BLOG from '@/blog.config' -import * as ThemeMap from '@/themes' const GlobalContext = createContext() let hasInit = false @@ -18,8 +17,6 @@ export function GlobalContextProvider ({ children }) { const [isDarkMode, updateDarkMode] = useState(false) const [onLoading, changeLoadingState] = useState(false) const [theme, setTheme] = useState(BLOG.THEME) - console.log('ThemeMap', ThemeMap) - const ThemeComponents = ThemeMap[theme] Router.events.on('routeChangeStart', (...args) => { changeLoadingState(true) @@ -39,7 +36,7 @@ export function GlobalContextProvider ({ children }) { }, 100) return ( - + {children} ) diff --git a/pages/404.js b/pages/404.js index b14f859b..29423e5f 100644 --- a/pages/404.js +++ b/pages/404.js @@ -1,4 +1,5 @@ import { useGlobal } from '@/lib/global' +import * as ThemeMap from '@/themes' /** * 自定义404界面 @@ -7,7 +8,7 @@ import { useGlobal } from '@/lib/global' */ export default function Custom404 (props) { - const { ThemeComponents } = useGlobal() - + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] return } diff --git a/pages/[slug].js b/pages/[slug].js index eda1bc51..d513f334 100644 --- a/pages/[slug].js +++ b/pages/[slug].js @@ -3,6 +3,7 @@ import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' import { useGlobal } from '@/lib/global' import Custom404 from './404' +import * as ThemeMap from '@/themes' /** * 根据notion的slug访问页面,针对类型为Page的页面 @@ -10,7 +11,8 @@ import Custom404 from './404' * @returns */ const Slug = (props) => { - const { ThemeComponents } = useGlobal() + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] if (!props.post) { return } diff --git a/pages/archive/index.js b/pages/archive/index.js index 6d974951..75bf91b1 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -1,9 +1,11 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import React from 'react' import { useGlobal } from '@/lib/global' +import * as ThemeMap from '@/themes' const ArchiveIndex = (props) => { - const { ThemeComponents } = useGlobal() + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] return } diff --git a/pages/article/[slug].js b/pages/article/[slug].js index 29a03539..bfe391d1 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -3,6 +3,7 @@ import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' import { useGlobal } from '@/lib/global' import Custom404 from '../404' +import * as ThemeMap from '@/themes' /** * 根据notion的slug访问页面 @@ -10,7 +11,8 @@ import Custom404 from '../404' * @returns */ const Slug = (props) => { - const { ThemeComponents } = useGlobal() + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] if (!props.post) { return } diff --git a/pages/category/[category].js b/pages/category/[category].js index 3362d419..9e9f5f3f 100644 --- a/pages/category/[category].js +++ b/pages/category/[category].js @@ -1,9 +1,11 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import React from 'react' import { useGlobal } from '@/lib/global' +import * as ThemeMap from '@/themes' export default function Category (props) { - const { ThemeComponents } = useGlobal() + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] return } diff --git a/pages/category/index.js b/pages/category/index.js index 22232a7d..dd195d4c 100644 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -1,9 +1,11 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import React from 'react' import { useGlobal } from '@/lib/global' +import * as ThemeMap from '@/themes' export default function Category (props) { - const { ThemeComponents } = useGlobal() + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] return } diff --git a/pages/index.js b/pages/index.js index 601e6671..02a15885 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,12 +1,11 @@ import BLOG from '@/blog.config' import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' +import * as ThemeMap from '@/themes' import { useGlobal } from '@/lib/global' const Index = (props) => { - const { ThemeComponents } = useGlobal() - // return - console.log(ThemeComponents) - // return <> + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] return } diff --git a/pages/page/[page].js b/pages/page/[page].js index 9d879940..0d6c1759 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -3,9 +3,11 @@ import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' import { useGlobal } from '@/lib/global' import Custom404 from '../404' +import * as ThemeMap from '@/themes' const Page = (props) => { - const { ThemeComponents } = useGlobal() + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] if (!props?.meta) { return } diff --git a/pages/search/[keyword].js b/pages/search/[keyword].js index 109768db..c00b6764 100644 --- a/pages/search/[keyword].js +++ b/pages/search/[keyword].js @@ -2,6 +2,7 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import { getDataFromCache } from '@/lib/cache/cache_manager' +import * as ThemeMap from '@/themes' const Index = (props) => { const { keyword } = props @@ -12,7 +13,8 @@ const Index = (props) => { type: 'website' } - const { ThemeComponents } = useGlobal() + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] return } diff --git a/pages/search/index.js b/pages/search/index.js index f0d266f3..bf0849d4 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -2,31 +2,7 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import { useRouter } from 'next/router' - -/** - * 浏览器前端搜索 - */ -export async function getStaticProps () { - const { - allPosts, - categories, - tags, - postCount, - latestPosts, - customNav - } = await getGlobalNotionData({ from: 'search-props', pageType: ['Post'] }) - return { - props: { - posts: allPosts, - tags, - categories, - postCount, - latestPosts, - customNav - }, - revalidate: 1 - } -} +import * as ThemeMap from '@/themes' const Search = (props) => { const { posts } = props @@ -51,11 +27,30 @@ const Search = (props) => { type: 'website' } - const { ThemeComponents } = useGlobal() + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] return } +/** + * 浏览器前端搜索 + */ +export async function getStaticProps () { + const { allPosts, categories, tags, postCount, latestPosts, customNav } = await getGlobalNotionData({ from: 'search-props', pageType: ['Post'] }) + return { + props: { + posts: allPosts, + tags, + categories, + postCount, + latestPosts, + customNav + }, + revalidate: 1 + } +} + function getSearchKey () { const router = useRouter() if (router.query && router.query.s) { diff --git a/pages/tag/[tag].js b/pages/tag/[tag].js index 90a5a9d2..238248bd 100644 --- a/pages/tag/[tag].js +++ b/pages/tag/[tag].js @@ -1,8 +1,10 @@ import { useGlobal } from '@/lib/global' import { getGlobalNotionData } from '@/lib/notion/getNotionData' +import * as ThemeMap from '@/themes' const Tag = (props) => { - const { ThemeComponents } = useGlobal() + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] return } diff --git a/pages/tag/index.js b/pages/tag/index.js index 90d0b9ec..d8a7911a 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -1,9 +1,11 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import React from 'react' import { useGlobal } from '@/lib/global' +import * as ThemeMap from '@/themes' const TagIndex = (props) => { - const { ThemeComponents } = useGlobal() + const { theme } = useGlobal() + const ThemeComponents = ThemeMap[theme] return } diff --git a/themes/Empty/LayoutPage.js b/themes/Empty/LayoutPage.js index f25ee48f..661a104b 100644 --- a/themes/Empty/LayoutPage.js +++ b/themes/Empty/LayoutPage.js @@ -1,4 +1,4 @@ -import LayoutBase from '../Empty/LayoutBase' +import LayoutBase from './LayoutBase' export const LayoutPage = (props) => { const { page } = props diff --git a/themes/Medium/components/BottomMenuBar.js b/themes/Medium/components/BottomMenuBar.js index e56b2601..8678afa7 100644 --- a/themes/Medium/components/BottomMenuBar.js +++ b/themes/Medium/components/BottomMenuBar.js @@ -1,6 +1,6 @@ import Link from 'next/link' import React from 'react' -import JumpToTopButton from '@/themes/Medium/components/JumpToTopButton' +import JumpToTopButton from './JumpToTopButton' export default function BottomMenuBar ({ className }) { return ( diff --git a/themes/Medium/components/TopNavBar.js b/themes/Medium/components/TopNavBar.js index fcbb84fc..78daa747 100644 --- a/themes/Medium/components/TopNavBar.js +++ b/themes/Medium/components/TopNavBar.js @@ -1,6 +1,6 @@ -import LogoBar from '@/themes/Medium/components/LogoBar' import Link from 'next/link' import { useRouter } from 'next/router' +import LogoBar from './LogoBar' /** * 顶部导航栏 + 菜单 From 56bf882fe39ccf769ce6aa37dee8f0f19ca05854 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 4 Mar 2022 17:14:10 +0800 Subject: [PATCH 14/42] =?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 43ff9846ab4755056541506a0fdcb504c6872a5d Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 8 Mar 2022 13:18:48 +0800 Subject: [PATCH 15/42] =?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 } export default MenuButtonGroupTop From b4e4ad384577ba4219e7bf2f27d67d43e28cbce8 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 15 Mar 2022 13:32:39 +0800 Subject: [PATCH 33/42] =?UTF-8?q?=E5=88=87=E6=8D=A2=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/themes/index.js b/themes/index.js index d47d2a42..286446ca 100644 --- a/themes/index.js +++ b/themes/index.js @@ -1,7 +1,6 @@ /** - * 修改 from 后面的路径,实现主题切换 + * 切换主题请修改 blog.config.js 中的 THEME 字段 */ - import * as next from './next' import * as fukasawa from './fukasawa' import * as hexo from './hexo' From e5c696b3790bb153c30472e0027af8e8e9f83e35 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 15 Mar 2022 13:32:58 +0800 Subject: [PATCH 34/42] =?UTF-8?q?Medium=E4=B8=BB=E9=A2=98=E9=A1=B6?= =?UTF-8?q?=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Medium/components/TopNavBar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/Medium/components/TopNavBar.js b/themes/Medium/components/TopNavBar.js index 78daa747..7b1ffa21 100644 --- a/themes/Medium/components/TopNavBar.js +++ b/themes/Medium/components/TopNavBar.js @@ -21,11 +21,11 @@ export default function TopNavBar (props) { if (link.show) { const selected = (router.pathname === link.to) || (router.asPath === link.to) return -
-
{link.name}
+
{link.name}
{link.slot}
From 3ecc3679957bf705fa5303d1f4781e937dd70d90 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 15 Mar 2022 13:35:34 +0800 Subject: [PATCH 35/42] =?UTF-8?q?Medium=E4=B8=BB=E9=A2=98=E9=A1=B6?= =?UTF-8?q?=E9=83=A8=E5=AF=BC=E8=88=AA=E6=A0=8F=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Medium/components/LogoBar.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/themes/Medium/components/LogoBar.js b/themes/Medium/components/LogoBar.js index ed622890..9bb3aa30 100644 --- a/themes/Medium/components/LogoBar.js +++ b/themes/Medium/components/LogoBar.js @@ -2,11 +2,9 @@ import BLOG from '@/blog.config' import Link from 'next/link' export default function LogoBar () { - return
-
+ return
} From a15fc196b27db98e4b72bc786fee890b59b04e5a Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 15 Mar 2022 15:40:29 +0800 Subject: [PATCH 36/42] =?UTF-8?q?hexo=E4=B8=BB=E9=A2=98=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Hexo/components/Header.js | 5 +++-- themes/Hexo/components/MenuButtonGroupTop.js | 2 +- themes/Hexo/components/TopNav.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/themes/Hexo/components/Header.js b/themes/Hexo/components/Header.js index 25c06f1c..5a335ddb 100644 --- a/themes/Hexo/components/Header.js +++ b/themes/Hexo/components/Header.js @@ -51,7 +51,7 @@ export default function Header () { const scrollS = window.scrollY const nav = document.querySelector('#sticky-nav') - if (scrollS < 300) { + if (scrollS < 500) { nav && nav.classList.replace('bg-white', 'bg-none') nav && nav.classList.replace('text-black', 'text-white') } else { @@ -59,6 +59,7 @@ export default function Header () { nav && nav.classList.replace('text-white', 'text-black') } + // 自动滚动 if ((scrollS > windowTop) & (scrollS < window.innerHeight) && !autoScroll ) { autoScroll = true @@ -98,7 +99,7 @@ export default function Header () { return (