theme 加载优化

This commit is contained in:
tangly1024.com
2024-01-30 12:50:13 +08:00
parent 7b56f15d4d
commit b415446aa6
12 changed files with 185 additions and 241 deletions

View File

@@ -133,9 +133,9 @@ const LayoutPostList = props => {
slotTop = props.slotTop
}
return (
<LayoutBase {...props} slotTop={slotTop}>
<div {...props} slotTop={slotTop}>
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogListPage {...props} /> : <BlogListScroll {...props} />}
</LayoutBase>
</div>
)
}
@@ -147,7 +147,7 @@ const LayoutPostList = props => {
const LayoutSlug = props => {
const { post, lock, validPassword } = props
return (
<LayoutBase {...props}>
<div {...props}>
{lock
? <ArticleLock validPassword={validPassword} />
: <div id="article-wrapper" className="px-2">
@@ -156,7 +156,7 @@ const LayoutSlug = props => {
<ShareBar post={post} />
<Comment frontMatter={post} />
</div>}
</LayoutBase>
</div>
)
}
@@ -166,7 +166,7 @@ const LayoutSlug = props => {
* @returns
*/
const Layout404 = (props) => {
return <LayoutBase {...props}>404 Not found.</LayoutBase>
return <div {...props}>404 Not found.</div>
}
/**
@@ -207,13 +207,13 @@ const LayoutSearch = props => {
const LayoutArchive = props => {
const { archivePosts } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div className="mb-10 pb-20 md:py-12 p-3 min-h-screen w-full">
{Object.keys(archivePosts).map(archiveTitle => (
<BlogListGroupByDate key={archiveTitle} archiveTitle={archiveTitle} archivePosts={archivePosts} />
))}
</div>
</LayoutBase>
</div>
)
}
@@ -225,11 +225,11 @@ const LayoutArchive = props => {
const LayoutCategoryIndex = props => {
const { categoryOptions } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div id='category-list' className='duration-200 flex flex-wrap'>
{categoryOptions?.map(category => <CategoryItem key={category.name} category={category} />)}
</div>
</LayoutBase>
</div>
)
}
@@ -241,16 +241,17 @@ const LayoutCategoryIndex = props => {
const LayoutTagIndex = (props) => {
const { tagOptions } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div id='tags-list' className='duration-200 flex flex-wrap'>
{tagOptions.map(tag => <TagItem key={tag.name} tag={tag} />)}
</div>
</LayoutBase>
</div>
)
}
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutPostList,
LayoutSearch,

View File

@@ -126,12 +126,12 @@ const LayoutIndex = (props) => {
* @param {*} props
*/
const LayoutPostList = (props) => {
return <LayoutBase {...props}>
return <div {...props}>
<div className='w-full p-2'><WWAds className='w-full' orientation='horizontal'/></div>
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogListPage {...props} /> : <BlogListScroll {...props} />}
</LayoutBase>
</div>
}
/**
@@ -142,9 +142,9 @@ const LayoutPostList = (props) => {
const LayoutSlug = (props) => {
const { lock, validPassword } = props
return (
<LayoutBase {...props} >
<div {...props} >
{lock ? <ArticleLock validPassword={validPassword} /> : <ArticleDetail {...props} />}
</LayoutBase>
</div>
)
}
@@ -174,7 +174,7 @@ const LayoutSearch = props => {
*/
const LayoutArchive = (props) => {
const { archivePosts } = props
return <LayoutBase {...props}>
return <div {...props}>
<div className="mb-10 pb-20 bg-white md:p-12 p-3 dark:bg-gray-800 shadow-md min-h-full">
{Object.keys(archivePosts).map(archiveTitle => (
<BlogArchiveItem
@@ -184,7 +184,7 @@ const LayoutArchive = (props) => {
/>
))}
</div>
</LayoutBase>
</div>
}
/**
@@ -193,7 +193,7 @@ const LayoutArchive = (props) => {
* @returns
*/
const Layout404 = props => {
return <LayoutBase {...props}>404</LayoutBase>
return <div {...props}>404</div>
}
/**
@@ -205,7 +205,7 @@ const LayoutCategoryIndex = (props) => {
const { locale } = useGlobal()
const { categoryOptions } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div className='bg-white dark:bg-gray-700 px-10 py-10 shadow'>
<div className='dark:text-gray-200 mb-5'>
<i className='mr-4 fas fa-th' />{locale.COMMON.CATEGORY}:
@@ -227,7 +227,7 @@ const LayoutCategoryIndex = (props) => {
})}
</div>
</div>
</LayoutBase>
</div>
)
}
@@ -239,7 +239,7 @@ const LayoutCategoryIndex = (props) => {
const LayoutTagIndex = (props) => {
const { locale } = useGlobal()
const { tagOptions } = props
return <LayoutBase {...props} >
return <div {...props} >
<div className='bg-white dark:bg-gray-700 px-10 py-10 shadow'>
<div className='dark:text-gray-200 mb-5'><i className='mr-4 fas fa-tag' />{locale.COMMON.TAGS}:</div>
<div id="tags-list" className="duration-200 flex flex-wrap ml-8">
@@ -252,11 +252,12 @@ const LayoutTagIndex = (props) => {
})}
</div>
</div>
</LayoutBase>
</div>
}
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutSearch,
LayoutArchive,

View File

@@ -193,7 +193,7 @@ const LayoutIndex = (props) => {
})
}, [])
return <LayoutBase {...props} />
return <div {...props} />
}
/**
@@ -203,9 +203,9 @@ const LayoutIndex = (props) => {
* @returns
*/
const LayoutPostList = (props) => {
return <LayoutBase {...props} >
return <div {...props} >
<div className='mt-10'><BlogPostListPage {...props} /></div>
</LayoutBase>
</div>
}
/**
@@ -217,7 +217,7 @@ const LayoutSlug = (props) => {
const { post, prev, next, lock, validPassword } = props
return (
<LayoutBase {...props} >
<div {...props} >
{/* 文章锁 */}
{lock && <ArticleLock validPassword={validPassword} />}
@@ -250,7 +250,7 @@ const LayoutSlug = (props) => {
<TocDrawer {...props} />
</div>}
</LayoutBase>
</div>
)
}
@@ -261,7 +261,7 @@ const LayoutSlug = (props) => {
* @returns
*/
const LayoutSearch = (props) => {
return <LayoutBase {...props}></LayoutBase>
return <div {...props}></div>
}
/**
@@ -273,20 +273,20 @@ const LayoutSearch = (props) => {
const LayoutArchive = (props) => {
const { archivePosts } = props
return <LayoutBase {...props}>
return <div {...props}>
<div className="mb-10 pb-20 md:py-12 py-3 min-h-full">
{Object.keys(archivePosts)?.map(archiveTitle => <BlogArchiveItem key={archiveTitle} archiveTitle={archiveTitle} archivePosts={archivePosts} />)}
</div>
</LayoutBase>
</div>
}
/**
* 404
*/
const Layout404 = props => {
return <LayoutBase {...props}>
return <div {...props}>
<div className='w-full h-96 py-80 flex justify-center items-center'>404 Not found.</div>
</LayoutBase>
</div>
}
/**
@@ -295,7 +295,7 @@ const Layout404 = props => {
const LayoutCategoryIndex = (props) => {
const { categoryOptions } = props
const { locale } = useGlobal()
return <LayoutBase {...props}>
return <div {...props}>
<div className='bg-white dark:bg-gray-700 py-10'>
<div className='dark:text-gray-200 mb-5'>
<i className='mr-4 fas fa-th' />{locale.COMMON.CATEGORY}:
@@ -317,7 +317,7 @@ const LayoutCategoryIndex = (props) => {
})}
</div>
</div>
</LayoutBase>
</div>
}
/**
@@ -327,7 +327,7 @@ const LayoutTagIndex = (props) => {
const { tagOptions } = props
const { locale } = useGlobal()
return <LayoutBase {...props}>
return <div {...props}>
<div className="bg-white dark:bg-gray-700 py-10">
<div className="dark:text-gray-200 mb-5">
<i className="mr-4 fas fa-tag" />
@@ -343,11 +343,12 @@ const LayoutTagIndex = (props) => {
})}
</div>
</div>
</LayoutBase>
</div>
}
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutSearch,
LayoutArchive,

View File

@@ -50,15 +50,38 @@ import { siteConfig } from '@/lib/config'
const LayoutBase = props => {
const {
children,
headerSlot,
slotTop,
slotRight,
className,
meta
} = props
// 全屏模式下的最大宽度
const { fullWidth } = useGlobal()
const router = useRouter()
console.log(router)
const headerSlot = (
<header>
{/* 顶部导航 */}
<div id="nav-bar-wrapper" className="h-16">
<NavBar {...props} />
</div>
{/* 通知横幅 */}
{router.route==='/' ? <>
<NoticeBar />
<Hero {...props} />
</>
: null}
<div className="max-w-[86rem] mx-auto px-3">
<WWAds className="w-full" orientation="horizontal" />
</div>
{fullWidth ? null : <PostHeader {...props} />}
</header>
)
// 右侧栏 用户信息+标签列表
const slotRight = fullWidth ? null : <SideRight {...props} />
const maxWidth = fullWidth ? 'max-w-[96rem] mx-auto' : 'max-w-[86rem]' // 普通最大宽度是86rem和顶部菜单栏对齐留空则与窗口对齐
const HEO_HERO_BODY_REVERSE = siteConfig('HEO_HERO_BODY_REVERSE', false, CONFIG)
@@ -115,26 +138,7 @@ const LayoutBase = props => {
* @returns
*/
const LayoutIndex = props => {
const headerSlot = (
<header>
{/* 顶部导航 */}
<div id="nav-bar-wrapper" className="h-16">
<NavBar {...props} />
</div>
{/* 通知横幅 */}
<NoticeBar />
<Hero {...props} />
<div className="max-w-[86rem] mx-auto px-3">
<WWAds className="w-full" orientation="horizontal" />
</div>
</header>
)
// 右侧栏 用户信息+标签列表
const slotRight = <SideRight {...props} />
return (
<LayoutBase {...props} slotRight={slotRight} headerSlot={headerSlot}>
<div id="post-outer-wrapper" className="px-5 md:px-0">
{/* 文章分类条 */}
<CategoryBar {...props} />
@@ -146,7 +150,6 @@ const LayoutIndex = props => {
<BlogPostListScroll {...props} />
)}
</div>
</LayoutBase>
)
}
@@ -156,19 +159,8 @@ const LayoutIndex = props => {
* @returns
*/
const LayoutPostList = props => {
// 右侧栏
const slotRight = <SideRight {...props} />
const headerSlot = (
<header>
{/* 顶部导航 */}
<div id="nav-bar-wrapper" className="h-16">
<NavBar {...props} />
</div>
</header>
)
return (
<LayoutBase {...props} slotRight={slotRight} headerSlot={headerSlot}>
<div id="post-outer-wrapper" className="px-5 md:px-0">
{/* 文章分类条 */}
<CategoryBar {...props} />
@@ -180,7 +172,6 @@ const LayoutPostList = props => {
<BlogPostListScroll {...props} />
)}
</div>
</LayoutBase>
)
}
@@ -193,16 +184,7 @@ const LayoutSearch = props => {
const { keyword } = props
const router = useRouter()
const currentSearch = keyword || router?.query?.s
const headerSlot = (
<header className="post-bg">
{/* 顶部导航 */}
<div id="nav-bar-wrapper">
<NavBar {...props} />
</div>
<PostHeader {...props} />
</header>
)
useEffect(() => {
// 高亮搜索结果
if (currentSearch) {
@@ -219,10 +201,9 @@ const LayoutSearch = props => {
}
}, [])
return (
<LayoutBase
<div
{...props}
currentSearch={currentSearch}
headerSlot={headerSlot}
>
<div id="post-outer-wrapper" className="px-5 md:px-0">
{!currentSearch
@@ -241,7 +222,7 @@ const LayoutSearch = props => {
</div>
)}
</div>
</LayoutBase>
</div>
)
}
@@ -253,21 +234,9 @@ const LayoutSearch = props => {
const LayoutArchive = props => {
const { archivePosts } = props
// 右侧栏
const slotRight = <SideRight {...props} />
const headerSlot = (
<header>
{/* 顶部导航 */}
<div id="nav-bar-wrapper" className="h-16">
<NavBar {...props} />
</div>
</header>
)
// 归档页顶部显示条,如果是默认归档则不显示。分类详情页显示分类列表,标签详情页显示当前标签
return (
<LayoutBase {...props} slotRight={slotRight} headerSlot={headerSlot}>
<div className="p-5 rounded-xl border dark:border-gray-600 max-w-6xl w-full bg-white dark:bg-[#1e1e1e]">
{/* 文章分类条 */}
<CategoryBar {...props} border={false} />
@@ -282,7 +251,6 @@ const LayoutArchive = props => {
))}
</div>
</div>
</LayoutBase>
)
}
@@ -302,34 +270,16 @@ const LayoutSlug = props => {
setHasCode(hasCode)
}, [])
// 右侧栏
const slotRight = fullWidth ? null : <SideRight {...props} />
const headerSlot = (
<header
data-aos="fade-up"
data-aos-duration="300"
data-aos-once="false"
data-aos-anchor-placement="top-bottom"
className="post-bg"
>
{/* 顶部导航 */}
<div id="nav-bar-wrapper">
<NavBar {...props} />
</div>
{fullWidth ? null : <PostHeader {...props} />}
</header>
)
const commentEnable = siteConfig('COMMENT_TWIKOO_ENV_ID') || siteConfig('COMMENT_WALINE_SERVER_URL') || siteConfig('COMMENT_VALINE_APP_ID') ||
siteConfig('COMMENT_GISCUS_REPO') || siteConfig('COMMENT_CUSDIS_APP_ID') || siteConfig('COMMENT_UTTERRANCES_REPO') ||
siteConfig('COMMENT_GITALK_CLIENT_ID') || siteConfig('COMMENT_WEBMENTION_ENABLE')
return (
<LayoutBase
<div
{...props}
headerSlot={headerSlot}
showCategory={false}
showTag={false}
slotRight={slotRight}
>
<div className={`w-full ${fullWidth ? '' : 'xl:max-w-5xl'} ${hasCode ? 'xl:w-[73.15vw]' : ''} lg:hover:shadow lg:border rounded-2xl lg:px-2 lg:py-4 bg-white dark:bg-[#18171d] dark:border-gray-600 article`}>
{lock && <ArticleLock validPassword={validPassword} />}
@@ -390,7 +340,7 @@ const LayoutSlug = props => {
)}
</div>
<FloatTocButton {...props} />
</LayoutBase>
</div>
)
}
@@ -477,18 +427,10 @@ const Layout404 = props => {
const LayoutCategoryIndex = props => {
const { categoryOptions } = props
const { locale } = useGlobal()
const headerSlot = (
<header>
{/* 顶部导航 */}
<div id="nav-bar-wrapper" className="h-16">
<NavBar {...props} />
</div>
</header>
)
return (
<LayoutBase {...props} className="mt-8" headerSlot={headerSlot}>
<div id="category-outer-wrapper" className="px-5 md:px-0">
<div id="category-outer-wrapper" className="mt-8 px-5 md:px-0">
<div className="text-4xl font-extrabold dark:text-gray-200 mb-5">
{locale.COMMON.CATEGORY}
</div>
@@ -520,7 +462,6 @@ const LayoutCategoryIndex = props => {
})}
</div>
</div>
</LayoutBase>
)
}
@@ -532,17 +473,9 @@ const LayoutCategoryIndex = props => {
const LayoutTagIndex = props => {
const { tagOptions } = props
const { locale } = useGlobal()
const headerSlot = (
<header>
{/* 顶部导航 */}
<div id="nav-bar-wrapper" className="h-16">
<NavBar {...props} />
</div>
</header>
)
return (
<LayoutBase {...props} className="mt-8" headerSlot={headerSlot}>
<div id="tag-outer-wrapper" className="px-5 md:px-0">
<div id="tag-outer-wrapper" className="px-5 mt-8 md:px-0">
<div className="text-4xl font-extrabold dark:text-gray-200 mb-5">
{locale.COMMON.TAGS}
</div>
@@ -574,12 +507,12 @@ const LayoutTagIndex = props => {
})}
</div>
</div>
</LayoutBase>
)
}
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutSearch,
LayoutArchive,

View File

@@ -46,8 +46,11 @@ export const useHexoGlobal = () => useContext(ThemeGlobalHexo)
* @constructor
*/
const LayoutBase = props => {
const { children, headerSlot, floatSlot, slotTop, meta, className } = props
const { children, floatSlot, slotTop, meta, className } = props
const { onLoading, fullWidth } = useGlobal()
const router = useRouter()
const headerSlot = router.route==='/' && siteConfig('HEXO_HOME_BANNER_ENABLE', null, CONFIG) ? <Hero {...props} /> : null
// Algolia搜索框
const searchModal = useRef(null)
@@ -125,8 +128,7 @@ const LayoutBase = props => {
* @returns
*/
const LayoutIndex = (props) => {
const headerSlot = siteConfig('HEXO_HOME_BANNER_ENABLE', null, CONFIG) && <Hero {...props} />
return <LayoutPostList {...props} headerSlot={headerSlot} className='pt-8' />
return <LayoutPostList {...props} className='pt-8' />
}
/**
@@ -135,10 +137,10 @@ const LayoutIndex = (props) => {
* @returns
*/
const LayoutPostList = (props) => {
return <LayoutBase {...props} className='pt-8'>
return <div {...props} className='pt-8'>
<SlotBar {...props} />
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogPostListPage {...props} /> : <BlogPostListScroll {...props} />}
</LayoutBase>
</div>
}
/**
@@ -165,11 +167,11 @@ const LayoutSearch = props => {
})
return (
<LayoutBase {...props} currentSearch={currentSearch} className='pt-8'>
<div {...props} currentSearch={currentSearch} className='pt-8'>
{!currentSearch
? <SearchNav {...props} />
: <div id="posts-wrapper"> {siteConfig('POST_LIST_STYLE') === 'page' ? <BlogPostListPage {...props} /> : <BlogPostListScroll {...props} />} </div>}
</LayoutBase>
</div>
)
}
@@ -180,7 +182,7 @@ const LayoutSearch = props => {
*/
const LayoutArchive = (props) => {
const { archivePosts } = props
return <LayoutBase {...props} className='pt-8'>
return <div {...props} className='pt-8'>
<Card className='w-full'>
<div className="mb-10 pb-20 bg-white md:p-12 p-3 min-h-full dark:bg-hexo-black-gray">
{Object.keys(archivePosts).map(archiveTitle => (
@@ -192,7 +194,7 @@ const LayoutArchive = (props) => {
))}
</div>
</Card>
</LayoutBase>
</div>
}
/**
@@ -218,7 +220,7 @@ const LayoutSlug = props => {
</>
return (
<LayoutBase {...props} headerSlot={<PostHeader {...props} />} showCategory={false} showTag={false} floatSlot={floatSlot} >
<div {...props} headerSlot={<PostHeader {...props} />} showCategory={false} showTag={false} floatSlot={floatSlot} >
<div className="w-full lg:hover:shadow lg:border rounded-t-xl lg:rounded-xl lg:px-2 lg:py-4 bg-white dark:bg-hexo-black-gray dark:border-black article">
{lock && <ArticleLock validPassword={validPassword} />}
@@ -253,7 +255,7 @@ const LayoutSlug = props => {
<TocDrawer post={post} cRef={drawerRight} targetRef={targetRef} />
</div>
</LayoutBase>
</div>
)
}
@@ -278,7 +280,7 @@ const Layout404 = props => {
}, 3000)
})
return (
<LayoutBase {...props}>
<div {...props}>
<div className="text-black w-full h-screen text-center justify-center content-center items-center flex flex-col">
<div className="dark:text-gray-200">
<h2 className="inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top">
@@ -289,7 +291,7 @@ const Layout404 = props => {
</div>
</div>
</div>
</LayoutBase>
</div>
)
}
@@ -302,7 +304,7 @@ const LayoutCategoryIndex = props => {
const { categoryOptions } = props
const { locale } = useGlobal()
return (
<LayoutBase {...props} className='mt-8'>
<div {...props} className='mt-8'>
<Card className="w-full min-h-screen">
<div className="dark:text-gray-200 mb-5 mx-3">
<i className="mr-4 fas fa-th" /> {locale.COMMON.CATEGORY}:
@@ -319,7 +321,7 @@ const LayoutCategoryIndex = props => {
})}
</div>
</Card>
</LayoutBase>
</div>
)
}
@@ -332,7 +334,7 @@ const LayoutTagIndex = props => {
const { tagOptions } = props
const { locale } = useGlobal()
return (
<LayoutBase {...props} className='mt-8'>
<div {...props} className='mt-8'>
<Card className='w-full'>
<div className="dark:text-gray-200 mb-5 ml-4">
<i className="mr-4 fas fa-tag" /> {locale.COMMON.TAGS}:
@@ -343,12 +345,13 @@ const LayoutTagIndex = props => {
</div>)}
</div>
</Card>
</LayoutBase>
</div>
)
}
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutSearch,
LayoutArchive,

View File

@@ -57,13 +57,13 @@ const LayoutBase = (props) => {
*/
const LayoutIndex = (props) => {
return (
<LayoutBase {...props}>
<div {...props}>
<Hero />
<Features />
<FeaturesBlocks />
<Testimonials />
<Newsletter />
</LayoutBase>
</div>
)
}
@@ -81,24 +81,25 @@ const LayoutSlug = (props) => {
return <div id='theme-landing'><Loading /></div>
}
return <LayoutBase {...props}>
return <div {...props}>
<div id='container-inner' className='mx-auto max-w-screen-lg p-12'>
<NotionPage {...props} />
</div>
</LayoutBase>
</div>
}
// 其他布局暂时留空
const LayoutSearch = (props) => <LayoutBase {...props}><Hero /></LayoutBase>
const LayoutArchive = (props) => <LayoutBase {...props}><Hero /></LayoutBase>
const Layout404 = (props) => <LayoutBase {...props}><Hero /></LayoutBase>
const LayoutCategoryIndex = (props) => <LayoutBase {...props}><Hero /></LayoutBase>
const LayoutPostList = (props) => <LayoutBase {...props}><Hero /></LayoutBase>
const LayoutTagIndex = (props) => <LayoutBase {...props}><Hero /></LayoutBase>
const LayoutSearch = (props) => <div {...props}><Hero /></div>
const LayoutArchive = (props) => <div {...props}><Hero /></div>
const Layout404 = (props) => <div {...props}><Hero /></div>
const LayoutCategoryIndex = (props) => <div {...props}><Hero /></div>
const LayoutPostList = (props) => <div {...props}><Hero /></div>
const LayoutTagIndex = (props) => <div {...props}><Hero /></div>
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutSearch,
LayoutArchive,

View File

@@ -40,9 +40,12 @@ import { siteConfig } from '@/lib/config'
* @constructor
*/
const LayoutBase = props => {
const { children, headerSlot, meta, siteInfo, containerSlot, post } = props
const { children, meta, siteInfo, post } = props
const { onLoading, fullWidth } = useGlobal()
const containerSlot= <Announcement {...props} />
const headerSlot= siteConfig('MATERY_HOME_BANNER_ENABLE', null, CONFIG) ? <Hero {...props} /> : null
return (
<div id='theme-matery' className="min-h-screen flex flex-col justify-between bg-hexo-background-gray dark:bg-black w-full">
{/* SEO相关 */}
@@ -113,7 +116,7 @@ const LayoutBase = props => {
* @returns
*/
const LayoutIndex = (props) => {
return <LayoutPostList {...props} containerSlot={<Announcement {...props} />} headerSlot={siteConfig('MATERY_HOME_BANNER_ENABLE', null, CONFIG) && <Hero {...props} />} />
return <LayoutPostList {...props}/>
}
/**
@@ -123,9 +126,9 @@ const LayoutIndex = (props) => {
*/
const LayoutPostList = (props) => {
return (
<LayoutBase {...props} containerSlot={<BlogListBar {...props} />}>
<div {...props} containerSlot={<BlogListBar {...props} />}>
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogPostListPage {...props} /> : <BlogPostListScroll {...props} />}
</LayoutBase>
</div>
)
}
@@ -152,13 +155,13 @@ const LayoutSearch = props => {
}
})
return (
<LayoutBase {...props} currentSearch={currentSearch}>
<div {...props} currentSearch={currentSearch}>
{!currentSearch
? <SearchNave {...props} />
: <div id="posts-wrapper">
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogPostListPage {...props} /> : <BlogPostListScroll {...props} />}
</div>}
</LayoutBase>
</div>
)
}
@@ -169,7 +172,7 @@ const LayoutSearch = props => {
*/
const LayoutArchive = (props) => {
const { archivePosts } = props
return <LayoutBase {...props} headerSlot={<PostHeader {...props} />} >
return <div {...props} headerSlot={<PostHeader {...props} />} >
<Card className='w-full -mt-32'>
<div className="mb-10 pb-20 bg-white md:p-12 p-3 min-h-full dark:bg-hexo-black-gray">
{Object.keys(archivePosts).map(archiveTitle => (
@@ -181,7 +184,7 @@ const LayoutArchive = (props) => {
))}
</div>
</Card>
</LayoutBase>
</div>
}
/**
@@ -194,7 +197,7 @@ const LayoutSlug = props => {
const { fullWidth } = useGlobal()
const headerSlot = fullWidth ? null : <PostHeader {...props} />
return (<LayoutBase {...props} headerSlot={headerSlot} showCategory={false} showTag={false} floatRightBottom={<JumpToCommentButton />}>
return (<div {...props} headerSlot={headerSlot} showCategory={false} showTag={false} floatRightBottom={<JumpToCommentButton />}>
<div id='inner-wrapper' className={`w-full ${fullWidth ? '' : 'lg:max-w-3xl 2xl:max-w-4xl'}`} >
@@ -257,7 +260,7 @@ const LayoutSlug = props => {
</div>
</LayoutBase>
</div>
)
}
@@ -280,7 +283,7 @@ const Layout404 = props => {
}, 3000)
})
return (
<LayoutBase {...props}>
<div {...props}>
<div className="text-black w-full h-screen text-center justify-center content-center items-center flex flex-col">
<div className="dark:text-gray-200">
<h2 className="inline-block border-r-2 border-gray-600 mr-2 px-3 py-2 align-top">
@@ -291,7 +294,7 @@ const Layout404 = props => {
</div>
</div>
</div>
</LayoutBase>
</div>
)
}
@@ -304,7 +307,7 @@ const LayoutCategoryIndex = props => {
const { categoryOptions } = props
return (
<LayoutBase {...props} headerSlot={<PostHeader {...props} />} >
<div {...props} headerSlot={<PostHeader {...props} />} >
<div id='inner-wrapper' className='w-full'>
<div className="drop-shadow-xl -mt-32 rounded-md mx-3 px-5 lg:border lg:rounded-xl lg:px-2 lg:py-4 bg-white dark:bg-hexo-black-gray dark:border-black dark:text-gray-300">
@@ -321,7 +324,7 @@ const LayoutCategoryIndex = props => {
</div>
</div>
</div>
</LayoutBase>
</div>
)
}
@@ -334,7 +337,7 @@ const LayoutTagIndex = props => {
const { tagOptions } = props
const { locale } = useGlobal()
return (
<LayoutBase {...props} headerSlot={<PostHeader {...props} />} >
<div {...props} headerSlot={<PostHeader {...props} />} >
<div id='inner-wrapper' className='w-full drop-shadow-xl'>
<div className="-mt-32 rounded-md mx-3 px-5 lg:border lg:rounded-xl lg:px-2 lg:py-4 bg-white dark:bg-hexo-black-gray dark:border-black">
@@ -354,12 +357,13 @@ const LayoutTagIndex = props => {
</div>
</div>
</div>
</LayoutBase>
</div>
)
}
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutPostList,
LayoutSearch,

View File

@@ -138,9 +138,9 @@ const LayoutIndex = (props) => {
*/
const LayoutPostList = (props) => {
const slotTop = <BlogPostBar {...props} />
return <LayoutBase {...props} slotTop={slotTop}>
return <div {...props} slotTop={slotTop}>
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogPostListPage {...props} /> : <BlogPostListScroll {...props} />}
</LayoutBase>
</div>
}
/**
@@ -158,7 +158,7 @@ const LayoutSlug = props => {
)
return (
<LayoutBase showInfoCard={true} slotRight={slotRight} {...props} >
<div showInfoCard={true} slotRight={slotRight} {...props} >
{/* 文章锁 */}
{lock && <ArticleLock validPassword={validPassword} />}
@@ -192,7 +192,7 @@ const LayoutSlug = props => {
{/* 移动端目录 */}
<TocDrawer {...props} />
</div>}
</LayoutBase>
</div>
)
}
@@ -220,7 +220,7 @@ const LayoutSearch = (props) => {
}
}, [])
return <LayoutBase {...props}>
return <div {...props}>
{/* 搜索导航栏 */}
<div className='py-12'>
@@ -236,7 +236,7 @@ const LayoutSearch = (props) => {
{currentSearch && <div>
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogPostListPage {...props} /> : <BlogPostListScroll {...props} />}
</div>}
</LayoutBase>
</div>
}
/**
@@ -247,12 +247,12 @@ const LayoutSearch = (props) => {
const LayoutArchive = props => {
const { archivePosts } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div className="mb-10 pb-20 md:py-12 py-3 min-h-full">
{Object.keys(archivePosts)?.map(archiveTitle => <BlogArchiveItem key={archiveTitle} archiveTitle={archiveTitle} archivePosts={archivePosts} />
)}
</div>
</LayoutBase>
</div>
)
}
@@ -262,9 +262,9 @@ const LayoutArchive = props => {
* @returns
*/
const Layout404 = props => {
return <LayoutBase {...props}>
return <div {...props}>
<div className='w-full h-96 py-80 flex justify-center items-center'>404 Not found.</div>
</LayoutBase>
</div>
}
/**
@@ -276,7 +276,7 @@ const LayoutCategoryIndex = (props) => {
const { categoryOptions } = props
const { locale } = useGlobal()
return (
<LayoutBase {...props}>
<div {...props}>
<div className='bg-white dark:bg-gray-700 py-10'>
<div className='dark:text-gray-200 mb-5'>
<i className='mr-4 fas fa-th' />{locale.COMMON.CATEGORY}:
@@ -298,7 +298,7 @@ const LayoutCategoryIndex = (props) => {
})}
</div>
</div>
</LayoutBase>
</div>
)
}
@@ -311,7 +311,7 @@ const LayoutTagIndex = props => {
const { tagOptions } = props
const { locale } = useGlobal()
return (
<LayoutBase {...props}>
<div {...props}>
<div className="bg-white dark:bg-gray-700 py-10">
<div className="dark:text-gray-200 mb-5">
<i className="mr-4 fas fa-tag" />
@@ -327,12 +327,13 @@ const LayoutTagIndex = props => {
})}
</div>
</div>
</LayoutBase>
</div>
)
}
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutPostList,
LayoutSearch,

View File

@@ -172,10 +172,10 @@ const LayoutPostListIndex = props => {
// const { customMenu, children, post, allNavPages, categoryOptions, slotLeft, slotRight, slotTop, meta } = props
// const [filteredNavPages, setFilteredNavPages] = useState(allNavPages)
return (
<LayoutBase {...props} >
<div {...props} >
<Announcement {...props} />
<BlogPostListAll { ...props } />
</LayoutBase>
</div>
)
}
@@ -189,7 +189,7 @@ const LayoutPostList = props => {
// 顶部如果是按照分类或标签查看文章列表,列表顶部嵌入一个横幅
// 如果是搜索,则列表顶部嵌入 搜索框
return (
<LayoutBase {...props} >
<div {...props} >
<div className='w-full max-w-7xl mx-auto justify-center mt-8'>
<div id='posts-wrapper' class='card-list grid gap-4 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5'>
{posts?.map(post => (
@@ -197,7 +197,7 @@ const LayoutPostList = props => {
))}
</div>
</div>
</LayoutBase>
</div>
)
}
@@ -210,7 +210,7 @@ const LayoutSlug = (props) => {
const { post, lock, validPassword } = props
return (
<LayoutBase {...props} >
<div {...props} >
{/* 文章锁 */}
{lock && <ArticleLock validPassword={validPassword} />}
@@ -244,7 +244,7 @@ const LayoutSlug = (props) => {
<TocDrawer {...props} />
</div>}
</LayoutBase>
</div>
)
}
@@ -255,7 +255,7 @@ const LayoutSlug = (props) => {
* @returns
*/
const LayoutSearch = (props) => {
return <LayoutBase {...props}></LayoutBase>
return <div {...props}></div>
}
/**
@@ -267,20 +267,20 @@ const LayoutSearch = (props) => {
const LayoutArchive = (props) => {
const { archivePosts } = props
return <LayoutBase {...props}>
return <div {...props}>
<div className="mb-10 pb-20 md:py-12 py-3 min-h-full">
{Object.keys(archivePosts)?.map(archiveTitle => <BlogArchiveItem key={archiveTitle} archiveTitle={archiveTitle} archivePosts={archivePosts} />)}
</div>
</LayoutBase>
</div>
}
/**
* 404
*/
const Layout404 = props => {
return <LayoutBase {...props}>
return <div {...props}>
<div className='w-full h-96 py-80 flex justify-center items-center'>404 Not found.</div>
</LayoutBase>
</div>
}
/**
@@ -289,7 +289,7 @@ const Layout404 = props => {
const LayoutCategoryIndex = (props) => {
const { categoryOptions } = props
const { locale } = useGlobal()
return <LayoutBase {...props}>
return <div {...props}>
<div className='bg-white dark:bg-gray-700 py-10'>
<div className='dark:text-gray-200 mb-5'>
<i className='mr-4 fas fa-th' />{locale.COMMON.CATEGORY}:
@@ -311,7 +311,7 @@ const LayoutCategoryIndex = (props) => {
})}
</div>
</div>
</LayoutBase>
</div>
}
/**
@@ -321,7 +321,7 @@ const LayoutTagIndex = (props) => {
const { tagOptions } = props
const { locale } = useGlobal()
return <LayoutBase {...props}>
return <div {...props}>
<div className="bg-white dark:bg-gray-700 py-10">
<div className="dark:text-gray-200 mb-5">
<i className="mr-4 fas fa-tag" />
@@ -337,11 +337,12 @@ const LayoutTagIndex = (props) => {
})}
</div>
</div>
</LayoutBase>
</div>
}
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutSearch,
LayoutArchive,

View File

@@ -130,10 +130,10 @@ const LayoutPostList = props => {
}
return (
<LayoutBase {...props} topSlot={<BlogListBar {...props} setFilterKey={setFilterKey} />}>
<div {...props} topSlot={<BlogListBar {...props} setFilterKey={setFilterKey} />}>
{topSlot}
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogListPage {...props} posts={filteredBlogPosts} /> : <BlogListScroll {...props} posts={filteredBlogPosts} />}
</LayoutBase>
</div>
)
}
@@ -171,10 +171,10 @@ const LayoutSearch = props => {
filteredBlogPosts = deepClone(posts)
}
return <LayoutBase {...props} topSlot={<BlogListBar {...props} setFilterKey={setFilterKey} />}>
return <div {...props} topSlot={<BlogListBar {...props} setFilterKey={setFilterKey} />}>
<SearchNavBar {...props} />
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogListPage {...props} posts={filteredBlogPosts} /> : <BlogListScroll {...props} posts={filteredBlogPosts} />}
</LayoutBase>
</div>
}
/**
@@ -185,11 +185,11 @@ const LayoutSearch = props => {
const LayoutArchive = props => {
const { archivePosts } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div className="mb-10 pb-20 md:py-12 p-3 min-h-screen w-full">
{Object.keys(archivePosts).map(archiveTitle => <BlogArchiveItem key={archiveTitle} archiveTitle={archiveTitle} archivePosts={archivePosts} />)}
</div>
</LayoutBase>
</div>
)
}
@@ -202,7 +202,7 @@ const LayoutSlug = props => {
const { post, lock, validPassword } = props
return (
<LayoutBase {...props}>
<div {...props}>
{lock && <ArticleLock validPassword={validPassword} />}
@@ -216,7 +216,7 @@ const LayoutSlug = props => {
</>
</div>}
</LayoutBase>
</div>
)
}
@@ -226,9 +226,9 @@ const LayoutSlug = props => {
* @returns
*/
const Layout404 = (props) => {
return <LayoutBase {...props}>
return <div {...props}>
404 Not found.
</LayoutBase>
</div>
}
/**
@@ -240,7 +240,7 @@ const LayoutCategoryIndex = (props) => {
const { categoryOptions } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div id='category-list' className='duration-200 flex flex-wrap'>
{categoryOptions?.map(category => {
return (
@@ -257,7 +257,7 @@ const LayoutCategoryIndex = (props) => {
)
})}
</div>
</LayoutBase>
</div>
)
}
@@ -269,7 +269,7 @@ const LayoutCategoryIndex = (props) => {
const LayoutTagIndex = (props) => {
const { tagOptions } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div>
<div id='tags-list' className='duration-200 flex flex-wrap'>
{tagOptions.map(tag => {
@@ -284,12 +284,13 @@ const LayoutTagIndex = (props) => {
})}
</div>
</div>
</LayoutBase>
</div>
)
}
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutSearch,
LayoutArchive,

View File

@@ -98,9 +98,9 @@ const LayoutIndex = props => {
*/
const LayoutPostList = props => {
return (
<LayoutBase {...props}>
<div {...props}>
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogListPage {...props} /> : <BlogListScroll {...props} />}
</LayoutBase>
</div>
)
}
@@ -137,11 +137,11 @@ const LayoutSearch = props => {
const LayoutArchive = props => {
const { archivePosts } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div className="mb-10 pb-20 md:py-12 p-3 min-h-screen w-full">
{Object.keys(archivePosts).map(archiveTitle => <BlogArchiveItem key={archiveTitle} archiveTitle={archiveTitle} archivePosts={archivePosts} />)}
</div>
</LayoutBase>
</div>
)
}
@@ -154,7 +154,7 @@ const LayoutSlug = props => {
const { post, lock, validPassword } = props
return (
<LayoutBase {...props}>
<div {...props}>
{lock && <ArticleLock validPassword={validPassword} />}
@@ -168,7 +168,7 @@ const LayoutSlug = props => {
</>
</div>}
</LayoutBase>
</div>
)
}
@@ -178,9 +178,9 @@ const LayoutSlug = props => {
* @returns
*/
const Layout404 = (props) => {
return <LayoutBase {...props}>
return <div {...props}>
404 Not found.
</LayoutBase>
</div>
}
/**
@@ -192,7 +192,7 @@ const LayoutCategoryIndex = (props) => {
const { categoryOptions } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div id='category-list' className='duration-200 flex flex-wrap'>
{categoryOptions?.map(category => {
return (
@@ -209,7 +209,7 @@ const LayoutCategoryIndex = (props) => {
)
})}
</div>
</LayoutBase>
</div>
)
}
@@ -221,7 +221,7 @@ const LayoutCategoryIndex = (props) => {
const LayoutTagIndex = (props) => {
const { tagOptions } = props
return (
<LayoutBase {...props}>
<div {...props}>
<div>
<div id='tags-list' className='duration-200 flex flex-wrap'>
{tagOptions.map(tag => {
@@ -236,12 +236,13 @@ const LayoutTagIndex = (props) => {
})}
</div>
</div>
</LayoutBase>
</div>
)
}
export {
CONFIG as THEME_CONFIG,
LayoutBase,
LayoutIndex,
LayoutSearch,
LayoutArchive,

View File

@@ -2,7 +2,6 @@ import { AdSlot } from '@/components/GoogleAdsense'
import Live2D from '@/components/Live2D'
import Announcement from './Announcement'
import Catalog from './Catalog'
import { useEffect } from 'react'
/**
* 侧边栏
@@ -12,9 +11,6 @@ import { useEffect } from 'react'
let counter = 0;
export default function SideBar (props) {
const { notice } = props
useEffect(()=>{
console.log('sidebar 渲染次数: ', counter++)
}, [])
return (<>
<aside>