From 69422fff7f070f7c1ca7a43a601a581bbb3c93ba Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 8 Mar 2022 18:06:37 +0800 Subject: [PATCH] =?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 }