首屏打开优化;
banner图加入配置;
This commit is contained in:
tangly1024
2021-12-24 12:31:02 +08:00
parent 72cc521ae6
commit 4fd338119f
5 changed files with 18 additions and 25 deletions

View File

@@ -5,6 +5,7 @@ const BLOG = {
link: 'https://tangly1024.com', link: 'https://tangly1024.com',
description: '分享编程技术与记录生活', description: '分享编程技术与记录生活',
headerStrings: ['Hi我是一个程序员', 'Hi我是一个打工人', 'Hi我是一个干饭人', '欢迎来到我的博客🎉'], // 首页文字 headerStrings: ['Hi我是一个程序员', 'Hi我是一个打工人', 'Hi我是一个干饭人', '欢迎来到我的博客🎉'], // 首页文字
bannerImage: './bg_image.jpg', // 首图
lang: 'zh-CN', // ['zh-CN','en-US'] default lang => see /lib/lang.js for more. lang: 'zh-CN', // ['zh-CN','en-US'] default lang => see /lib/lang.js for more.
notionPageId: process.env.NOTION_PAGE_ID || 'bee1fccfa3bd47a1a7be83cc71372d83', // Important page_id notionPageId: process.env.NOTION_PAGE_ID || 'bee1fccfa3bd47a1a7be83cc71372d83', // Important page_id
notionAccessToken: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public notionAccessToken: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public

View File

@@ -1,6 +1,6 @@
import BLOG from '@/blog.config' import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import { faArrowDown } from '@fortawesome/free-solid-svg-icons' import { faAngleDown } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { useCallback, useEffect, useState } from 'react' import { useCallback, useEffect, useState } from 'react'
import Typed from 'typed.js' import Typed from 'typed.js'
@@ -93,7 +93,7 @@ export default function Header () {
style={{ style={{
height: 'calc(100vh + 1px)', height: 'calc(100vh + 1px)',
backgroundImage: backgroundImage:
'linear-gradient(rgba(0, 0, 0, 0.5), rgba(0,0,0,0.4), rgba(0, 0, 0, 0.5) ),url("./bg_image.jpg")' `linear-gradient(rgba(0, 0, 0, 0.8), rgba(0,0,0,0.2), rgba(0, 0, 0, 0.8) ),url("${BLOG.bannerImage}")`
}} }}
> >
<div className="absolute z-10 flex h-full items-center -mt-14 justify-center w-full text-4xl md:text-7xl text-white"> <div className="absolute z-10 flex h-full items-center -mt-14 justify-center w-full text-4xl md:text-7xl text-white">
@@ -103,9 +103,9 @@ export default function Header () {
onClick={() => { onClick={() => {
scrollTo(wrapperTop, autoScrollEnd) scrollTo(wrapperTop, autoScrollEnd)
}} }}
className="cursor-pointer w-full text-center text-2xl animate-bounce absolute bottom-10 text-white" className="cursor-pointer w-full text-center py-4 text-5xl animate-bounce absolute bottom-10 text-white"
> >
<FontAwesomeIcon icon={faArrowDown} /> <FontAwesomeIcon icon={faAngleDown} />
</div> </div>
</header> </header>
) )

View File

@@ -7,7 +7,6 @@ import CategoryGroup from '@/components/CategoryGroup'
import SearchInput from '@/components/SearchInput' import SearchInput from '@/components/SearchInput'
import Link from 'next/link' import Link from 'next/link'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import Toc from '@/components/Toc'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faAngleDoubleRight, faArchive, faTags, faThList } from '@fortawesome/free-solid-svg-icons' import { faAngleDoubleRight, faArchive, faTags, faThList } from '@fortawesome/free-solid-svg-icons'
@@ -27,10 +26,7 @@ const SideBar = ({ title, tags, currentTag, post, posts, categories, currentCate
const { locale } = useGlobal() const { locale } = useGlobal()
return <aside id='sidebar' className='pt-5 bg-white dark:bg-gray-900 w-80 z-10 dark:border-gray-500 border-gray-200 scroll-hidden h-full'> return <aside id='sidebar' className='pt-5 bg-white dark:bg-gray-900 w-80 z-10 dark:border-gray-500 border-gray-200 scroll-hidden h-full'>
<section className='hidden lg:block'> <InfoCard />
<InfoCard />
<hr className='dark:border-gray-700 mt-6 py-1' />
</section>
<div className={(!post ? 'sticky top-0' : '') + ' bg-white dark:bg-gray-900 pb-4'}> <div className={(!post ? 'sticky top-0' : '') + ' bg-white dark:bg-gray-900 pb-4'}>
@@ -85,15 +81,6 @@ const SideBar = ({ title, tags, currentTag, post, posts, categories, currentCate
)} )}
</div> </div>
{post && (
<section id='left-toc' className='sticky pb-20 top-0 bg-white dark:bg-gray-900 hidden md:block'>
<div className='border-b text-2xl bg-white text-black dark:border-gray-700 dark:bg-gray-700 dark:text-white py-6 px-6'>
{locale.COMMON.TABLE_OF_CONTENTS}
</div>
<Toc toc={post.toc} />
</section>
)}
<section className='bg-white dark:bg-gray-900'> <section className='bg-white dark:bg-gray-900'>
{/* 信息流广告 */} {/* 信息流广告 */}
<ins className="adsbygoogle" <ins className="adsbygoogle"

View File

@@ -1,5 +1,5 @@
import React, { useImperativeHandle, useState } from 'react'
import SideBar from '@/components/SideBar' import SideBar from '@/components/SideBar'
import React, { useEffect, useImperativeHandle, useState } from 'react'
/** /**
* 侧边栏抽屉面板,可以从侧面拉出 * 侧边栏抽屉面板,可以从侧面拉出
@@ -13,8 +13,14 @@ const SideBarDrawer = ({ post, currentTag, cRef, tags, posts, categories, curren
handleSwitchSideDrawerVisible: () => switchSideDrawerVisible() handleSwitchSideDrawerVisible: () => switchSideDrawerVisible()
} }
}) })
const [isShow, changeHiddenStatus] = useState(false)
useEffect(() => {
const sideBarWrapperElement = document.getElementById('sidebar-wrapper')
sideBarWrapperElement?.classList?.remove('hidden')
})
// 点击按钮更改侧边抽屉状态 // 点击按钮更改侧边抽屉状态
const [isShow, changeHiddenStatus] = useState(false)
const switchSideDrawerVisible = () => { const switchSideDrawerVisible = () => {
const showStatus = !isShow const showStatus = !isShow
changeHiddenStatus(showStatus) changeHiddenStatus(showStatus)
@@ -31,15 +37,14 @@ const SideBarDrawer = ({ post, currentTag, cRef, tags, posts, categories, curren
} }
} }
} }
return <>
return <div id='sidebar-wrapper' className='hidden'>
<div id='sidebar-drawer' className='-ml-80 bg-white dark:bg-gray-900 flex flex-col duration-300 fixed h-full left-0 overflow-y-scroll scroll-hidden top-0 z-50'> <div id='sidebar-drawer' className='-ml-80 bg-white dark:bg-gray-900 flex flex-col duration-300 fixed h-full left-0 overflow-y-scroll scroll-hidden top-0 z-50'>
<SideBar tags={tags} post={post} posts={posts} categories={categories} currentCategory={currentCategory} /> <SideBar tags={tags} post={post} posts={posts} categories={categories} currentCategory={currentCategory} />
</div> </div>
{/* 背景蒙版 */} {/* 背景蒙版 */}
<div id='sidebar-drawer-background' <div id='sidebar-drawer-background' onClick={switchSideDrawerVisible} className='hidden fixed top-0 left-0 z-30 w-full h-full bg-black bg-opacity-30'/>
className='hidden fixed top-0 left-0 z-30 w-full h-full bg-black bg-opacity-30'
onClick={switchSideDrawerVisible} />
</> </div>
} }
export default SideBarDrawer export default SideBarDrawer

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 KiB

After

Width:  |  Height:  |  Size: 261 KiB