From 849566ae16bf617f33787f4ade1076f25c8f55ef Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 19 Jan 2022 17:22:36 +0800 Subject: [PATCH] =?UTF-8?q?Hexo=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/Empty/config_empty.js | 4 ++++ themes/Hexo/LayoutBase.js | 1 + themes/Hexo/LayoutIndex.js | 10 ++++++++-- themes/Hexo/components/Header.js | 10 +++++----- themes/Hexo/config_hexo.js | 6 ++++++ themes/index.js | 3 ++- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/themes/Empty/config_empty.js b/themes/Empty/config_empty.js index e69de29b..9f1ac567 100644 --- a/themes/Empty/config_empty.js +++ b/themes/Empty/config_empty.js @@ -0,0 +1,4 @@ +const CONFIG_EMPTY = { + TEST_CONFIG: 'TESET' +} +export default CONFIG_EMPTY diff --git a/themes/Hexo/LayoutBase.js b/themes/Hexo/LayoutBase.js index d302c580..87e54f0a 100644 --- a/themes/Hexo/LayoutBase.js +++ b/themes/Hexo/LayoutBase.js @@ -31,6 +31,7 @@ const LayoutBase = ({ }) => { return (<> + {headerSlot}
{children}
diff --git a/themes/Hexo/LayoutIndex.js b/themes/Hexo/LayoutIndex.js index 986951c3..83cf86e0 100644 --- a/themes/Hexo/LayoutIndex.js +++ b/themes/Hexo/LayoutIndex.js @@ -1,3 +1,9 @@ -export const LayoutIndex = ({ posts, tags, meta, categories, postCount, latestPosts }) => { - return
Index
+import Header from './components/Header' +import CONFIG_HEXO from './config_hexo' +import LayoutBase from './LayoutBase' + +export const LayoutIndex = (props) => { + return }> + + } diff --git a/themes/Hexo/components/Header.js b/themes/Hexo/components/Header.js index 2e18fbe3..f75f5d36 100644 --- a/themes/Hexo/components/Header.js +++ b/themes/Hexo/components/Header.js @@ -3,7 +3,7 @@ import { faAngleDown } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useEffect, useState } from 'react' import Typed from 'typed.js' -import CONFIG_NEXT from '../config_next' +import CONFIG_HEXO from '../config_hexo' let wrapperTop = 0 let windowTop = 0 @@ -19,7 +19,7 @@ export default function Header () { if (!typed && window && document.getElementById('typed')) { changeType( new Typed('#typed', { - strings: CONFIG_NEXT.HOME_BANNER_Strings, + strings: CONFIG_HEXO.HOME_BANNER_GREETINGS, typeSpeed: 200, backSpeed: 100, backDelay: 400, @@ -66,9 +66,9 @@ export default function Header () { if (theme !== 'dark') { const stickyNavElement = document.getElementById('sticky-nav') if (window.scrollY < window.innerHeight) { - stickyNavElement.classList.add('dark') + stickyNavElement?.classList?.add('dark') } else { - stickyNavElement.classList.remove('dark') + stickyNavElement?.classList?.remove('dark') } } } @@ -99,7 +99,7 @@ export default function Header () { className="duration-500 md:bg-fixed w-full bg-cover bg-center h-screen bg-black" style={{ backgroundImage: - `linear-gradient(rgba(0, 0, 0, 0.8), rgba(0,0,0,0.2), rgba(0, 0, 0, 0.8) ),url("${CONFIG_NEXT.HOME_BANNER_IMAGE}")` + `linear-gradient(rgba(0, 0, 0, 0.8), rgba(0,0,0,0.2), rgba(0, 0, 0, 0.8) ),url("${CONFIG_HEXO.HOME_BANNER_IMAGE}")` }} >
diff --git a/themes/Hexo/config_hexo.js b/themes/Hexo/config_hexo.js index e69de29b..6da54488 100644 --- a/themes/Hexo/config_hexo.js +++ b/themes/Hexo/config_hexo.js @@ -0,0 +1,6 @@ +const CONFIG_HEXO = { + HOME_BANNER_ENABLE: true, + HOME_BANNER_GREETINGS: ['Hi,我是一个程序员', 'Hi,我是一个打工人', 'Hi,我是一个干饭人', '欢迎来到我的博客🎉'], // 首页大图标语文字 + HOME_BANNER_IMAGE: './bg_image.jpg' // see /public/bg_image.jpg +} +export default CONFIG_HEXO diff --git a/themes/index.js b/themes/index.js index 5ec2485d..a519f091 100644 --- a/themes/index.js +++ b/themes/index.js @@ -2,6 +2,7 @@ * 修改 from 后面的路径,实现主题切换 */ -export * from './NEXT' // 切换主题 +// export * from './NEXT' // 切换主题 // export * from './Fukasawa' // export * from './Empty' +export * from './Hexo'