mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-15 07:26:48 +00:00
feature:
layout优化,图片优化
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import CommonHead from '@/components/CommonHead'
|
||||
import FloatDarkModeButton from '@/components/FloatDarkModeButton'
|
||||
import Footer from '@/components/Footer'
|
||||
import Header from '@/components/Header'
|
||||
import JumpToBottomButton from '@/components/JumpToBottomButton'
|
||||
import JumpToTopButton from '@/components/JumpToTopButton'
|
||||
import LoadingCover from '@/components/LoadingCover'
|
||||
@@ -9,7 +8,6 @@ import SideAreaRight from '@/components/SideAreaRight'
|
||||
import TopNav from '@/components/TopNav'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import throttle from 'lodash.throttle'
|
||||
import { useRouter } from 'next/router'
|
||||
import PropTypes from 'prop-types'
|
||||
import React, { useCallback, useEffect, useRef } from 'react'
|
||||
/**
|
||||
@@ -33,6 +31,7 @@ const BaseLayout = ({
|
||||
children,
|
||||
layout,
|
||||
fullWidth,
|
||||
headerSlot,
|
||||
tags,
|
||||
meta,
|
||||
post,
|
||||
@@ -65,40 +64,29 @@ const BaseLayout = ({
|
||||
}, [])
|
||||
const { onLoading } = useGlobal()
|
||||
const targetRef = useRef(null)
|
||||
const router = useRouter()
|
||||
console.log('header', headerSlot)
|
||||
|
||||
return (<>
|
||||
|
||||
<CommonHead meta={meta} />
|
||||
|
||||
{/* 顶部导航栏 */}
|
||||
{/* {router.asPath === '/as' && */}
|
||||
<TopNav tags={tags} post={post} posts={totalPosts} currentSearch={currentSearch} categories={categories} currentCategory={currentCategory} />
|
||||
{/* } */}
|
||||
<TopNav tags={tags} post={post} posts={totalPosts} currentSearch={currentSearch} categories={categories} currentCategory={currentCategory} />
|
||||
|
||||
{/* 首页头图 */}
|
||||
{router.asPath === '/' && <Header/>}
|
||||
<>{headerSlot}</>
|
||||
|
||||
<div id='wrapper' className='flex justify-center flex-1 mx-auto md:pt-8 pb-12'>
|
||||
|
||||
{/* <div id='left' className='hidden lg:block flex-col w-72'>
|
||||
<SideAreaLeft targetRef={targetRef} title={meta.title} post={post} posts={totalPosts} tags={tags} currentSearch={currentSearch} currentTag={currentTag} categories={categories} currentCategory={currentCategory} />
|
||||
</div> */}
|
||||
|
||||
<div id='center' className='flex-grow max-w-4xl min-h-screen md:mx-10' ref={targetRef}>
|
||||
<main id='wrapper' className='flex justify-center flex-1 mx-auto md:pt-8 pb-12'>
|
||||
<section id='center' className='flex-grow max-w-4xl min-h-screen md:mx-10' ref={targetRef}>
|
||||
{onLoading
|
||||
? <LoadingCover/>
|
||||
: <>
|
||||
{children}
|
||||
</>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div id='right' className='hidden lg:block flex-col w-72 mr-5'>
|
||||
</section>
|
||||
<aside id='right' className='hidden lg:block flex-col w-72 mr-5'>
|
||||
<SideAreaRight targetRef={targetRef} post={post} posts={totalPosts} tags={tags} currentSearch={currentSearch} currentTag={currentTag} categories={categories} currentCategory={currentCategory}/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</aside>
|
||||
</main>
|
||||
|
||||
<Footer title={meta.title}/>
|
||||
<JumpToTopButton targetRef={targetRef} showPercent={false} />
|
||||
|
||||
8
lib/cache/cache_manager.js
vendored
8
lib/cache/cache_manager.js
vendored
@@ -1,5 +1,5 @@
|
||||
import { getCacheFromMemory, setCacheToMemory } from '@/lib/cache/memory_cache'
|
||||
// import { getCacheFromFile, setCacheToFile } from './local_file_cache'
|
||||
// import { getCacheFromMemory, setCacheToMemory } from '@/lib/cache/memory_cache'
|
||||
import { getCacheFromFile, setCacheToFile } from './local_file_cache'
|
||||
const enableCache = true // 生产环境禁用
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,7 @@ export async function getDataFromCache (key) {
|
||||
if (!enableCache) {
|
||||
return null
|
||||
}
|
||||
const dataFromCache = await getCacheFromMemory(key)
|
||||
const dataFromCache = await getCacheFromFile(key)
|
||||
if (JSON.stringify(dataFromCache) === '[]') {
|
||||
return null
|
||||
}
|
||||
@@ -22,5 +22,5 @@ export async function setDataToCache (key, data) {
|
||||
if (!enableCache || !data) {
|
||||
return
|
||||
}
|
||||
await setCacheToMemory(key, data)
|
||||
await setCacheToFile(key, data)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import BLOG from '@/blog.config'
|
||||
import BaseLayout from '@/layouts/BaseLayout'
|
||||
import BlogPostListScroll from '@/components/BlogPostListScroll'
|
||||
import { getNotionPageData } from '@/lib/notion/getNotionData'
|
||||
import Header from '@/components/Header'
|
||||
|
||||
export async function getStaticProps () {
|
||||
const from = 'index'
|
||||
@@ -29,8 +30,14 @@ export async function getStaticProps () {
|
||||
|
||||
const Index = ({ allPosts, tags, meta, categories }) => {
|
||||
return (
|
||||
<BaseLayout meta={meta} tags={tags} totalPosts={allPosts} categories={categories}>
|
||||
<BlogPostListScroll posts={allPosts} tags={tags} />
|
||||
<BaseLayout
|
||||
headerSlot={<Header />}
|
||||
meta={meta}
|
||||
tags={tags}
|
||||
totalPosts={allPosts}
|
||||
categories={categories}
|
||||
>
|
||||
<BlogPostListScroll posts={allPosts} tags={tags} />
|
||||
</BaseLayout>
|
||||
)
|
||||
}
|
||||
|
||||
BIN
public/bg_image.jpg
Normal file → Executable file
BIN
public/bg_image.jpg
Normal file → Executable file
Binary file not shown.
|
Before Width: | Height: | Size: 538 KiB After Width: | Height: | Size: 289 KiB |
Reference in New Issue
Block a user