diff --git a/themes/hexo/index.js b/themes/hexo/index.js
index b36ff6e2..664b9698 100644
--- a/themes/hexo/index.js
+++ b/themes/hexo/index.js
@@ -1,39 +1,42 @@
-import CONFIG from './config'
-import { createContext, useContext, useEffect, useRef } from 'react'
-import Footer from './components/Footer'
-import SideRight from './components/SideRight'
-import TopNav from './components/TopNav'
+import Comment from '@/components/Comment'
+import replaceSearchResult from '@/components/Mark'
+import NotionPage from '@/components/NotionPage'
+import ShareBar from '@/components/ShareBar'
+import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import { isBrowser } from '@/lib/utils'
-import BlogPostListPage from './components/BlogPostListPage'
-import BlogPostListScroll from './components/BlogPostListScroll'
-import Hero from './components/Hero'
+import { Transition } from '@headlessui/react'
+import dynamic from 'next/dynamic'
+import Link from 'next/link'
import { useRouter } from 'next/router'
-import Card from './components/Card'
-import RightFloatArea from './components/RightFloatArea'
-import SearchNav from './components/SearchNav'
-import BlogPostArchive from './components/BlogPostArchive'
-import { ArticleLock } from './components/ArticleLock'
-import PostHeader from './components/PostHeader'
-import JumpToCommentButton from './components/JumpToCommentButton'
-import TocDrawer from './components/TocDrawer'
-import TocDrawerButton from './components/TocDrawerButton'
-import Comment from '@/components/Comment'
-import NotionPage from '@/components/NotionPage'
+import { createContext, useContext, useEffect, useRef } from 'react'
import ArticleAdjacent from './components/ArticleAdjacent'
import ArticleCopyright from './components/ArticleCopyright'
+import { ArticleLock } from './components/ArticleLock'
import ArticleRecommend from './components/ArticleRecommend'
-import ShareBar from '@/components/ShareBar'
-import TagItemMini from './components/TagItemMini'
-import Link from 'next/link'
+import BlogPostArchive from './components/BlogPostArchive'
+import BlogPostListPage from './components/BlogPostListPage'
+import BlogPostListScroll from './components/BlogPostListScroll'
+import Card from './components/Card'
+import Footer from './components/Footer'
+import Hero from './components/Hero'
+import JumpToCommentButton from './components/JumpToCommentButton'
+import PostHeader from './components/PostHeader'
+import RightFloatArea from './components/RightFloatArea'
+import SearchNav from './components/SearchNav'
+import SideRight from './components/SideRight'
import SlotBar from './components/SlotBar'
-import { Transition } from '@headlessui/react'
+import TagItemMini from './components/TagItemMini'
+import TocDrawer from './components/TocDrawer'
+import TocDrawerButton from './components/TocDrawerButton'
+import TopNav from './components/TopNav'
+import CONFIG from './config'
import { Style } from './style'
-import replaceSearchResult from '@/components/Mark'
-import { siteConfig } from '@/lib/config'
-import dynamic from 'next/dynamic'
-const AlgoliaSearchModal = dynamic(() => import('@/components/AlgoliaSearchModal'), { ssr: false })
+const AlgoliaSearchModal = dynamic(
+ () => import('@/components/AlgoliaSearchModal'),
+ { ssr: false }
+)
// 主题全局状态
const ThemeGlobalHexo = createContext()
@@ -50,93 +53,110 @@ const LayoutBase = props => {
const { onLoading, fullWidth } = useGlobal()
const router = useRouter()
- const headerSlot = post
- ?
- : (router.route === '/' && siteConfig('HEXO_HOME_BANNER_ENABLE', null, CONFIG)
- ?
- : null)
+ const headerSlot = post ? (
+
+ ) : router.route === '/' &&
+ siteConfig('HEXO_HOME_BANNER_ENABLE', null, CONFIG) ? (
+
+ ) : null
const drawerRight = useRef(null)
const tocRef = isBrowser ? document.getElementById('article-wrapper') : null
- const floatSlot = <>
- {post?.toc?.length > 1 &&
- {
- drawerRight?.current?.handleSwitchVisible()
- }}
- />
-
}
-
+ const floatSlot = (
+ <>
+ {post?.toc?.length > 1 && (
+
+ {
+ drawerRight?.current?.handleSwitchVisible()
+ }}
+ />
+
+ )}
+ {post && }
>
+ )
// Algolia搜索框
const searchModal = useRef(null)
return (
-
-
+
+
- {/* 顶部导航 */}
-
+ {/* 顶部导航 */}
+
- {/* 顶部嵌入 */}
-
+ {headerSlot}
+
+
+ {/* 主区块 */}
+
+
+
+
- {headerSlot}
-
+ enter='transition ease-in-out duration-700 transform order-first'
+ enterFrom='opacity-0 translate-y-16'
+ enterTo='opacity-100'
+ leave='transition ease-in-out duration-300 transform'
+ leaveFrom='opacity-100 translate-y-0'
+ leaveTo='opacity-0 -translate-y-16'
+ unmount={false}>
+ {/* 主区上部嵌入 */}
+ {slotTop}
- {/* 主区块 */}
-
-
-
-
-
- {/* 主区上部嵌入 */}
- {slotTop}
-
- {children}
-
-
-
- {/* 右侧栏 */}
-
-
-
-
-
-
+ {children}
+
- {/* 悬浮菜单 */}
-
+ {/* 右侧栏 */}
+
+
+
- {/* 全文搜索 */}
-
-
- {/* 页脚 */}
-
+
+
+
+ {/* 悬浮菜单 */}
+
+
+ {/* 全文搜索 */}
+
+
+ {/* 页脚 */}
+
+
)
}
@@ -147,7 +167,7 @@ const LayoutBase = props => {
* @param {*} props
* @returns
*/
-const LayoutIndex = (props) => {
+const LayoutIndex = props => {
return
}
@@ -156,11 +176,17 @@ const LayoutIndex = (props) => {
* @param {*} props
* @returns
*/
-const LayoutPostList = (props) => {
- return
-
- {siteConfig('POST_LIST_STYLE') === 'page' ?
:
}
+const LayoutPostList = props => {
+ return (
+
+
+ {siteConfig('POST_LIST_STYLE') === 'page' ? (
+
+ ) : (
+
+ )}
+ )
}
/**
@@ -187,11 +213,20 @@ const LayoutSearch = props => {
})
return (
-
- {!currentSearch
- ?
- :
{siteConfig('POST_LIST_STYLE') === 'page' ? : }
}
+
+ {!currentSearch ? (
+
+ ) : (
+
+ {' '}
+ {siteConfig('POST_LIST_STYLE') === 'page' ? (
+
+ ) : (
+
+ )}{' '}
+ )}
+
)
}
@@ -200,21 +235,23 @@ const LayoutSearch = props => {
* @param {*} props
* @returns
*/
-const LayoutArchive = (props) => {
+const LayoutArchive = props => {
const { archivePosts } = props
- return
-
-
- {Object.keys(archivePosts).map(archiveTitle => (
-
- ))}
-
-
+ return (
+
+
+
+ {Object.keys(archivePosts).map(archiveTitle => (
+
+ ))}
+
+
+ )
}
/**
@@ -228,51 +265,60 @@ const LayoutSlug = props => {
useEffect(() => {
// 404
if (!post) {
- setTimeout(() => {
- if (isBrowser) {
- const article = document.getElementById('notion-article')
- if (!article) {
- router.push('/404').then(() => {
- console.warn('找不到页面', router.asPath)
- })
+ setTimeout(
+ () => {
+ if (isBrowser) {
+ const article = document.getElementById('notion-article')
+ if (!article) {
+ router.push('/404').then(() => {
+ console.warn('找不到页面', router.asPath)
+ })
+ }
}
- }
- }, siteConfig('POST_WAITING_TIME_FOR_404') * 1000)
+ },
+ siteConfig('POST_WAITING_TIME_FOR_404') * 1000
+ )
}
}, [post])
return (
- <>
-
- {lock &&
}
+ <>
+
+ {lock &&
}
- {!lock &&
+ {!lock && (
+
+
+ {/* Notion文章主体 */}
+
-
- {/* Notion文章主体 */}
-
+ {/* 分享 */}
+
+ {post?.type === 'Post' && (
+ <>
+
+
+
+ >
+ )}
+
- {/* 分享 */}
-
- {post?.type === 'Post' && <>
-
-
-
- >}
+
-
-
-
-
- {/* 评论互动 */}
-
-
-
-
}
+ {/* 评论互动 */}
+
+
-
- >
+
+ )}
+
+ >
)
}
@@ -297,18 +343,18 @@ const Layout404 = props => {
}, 3000)
})
return (
- <>
-
- >
+ <>
+
+ >
)
}
@@ -321,24 +367,32 @@ const LayoutCategoryIndex = props => {
const { categoryOptions } = props
const { locale } = useGlobal()
return (
-
-
-
- {locale.COMMON.CATEGORY}:
-
-
- {categoryOptions?.map(category => {
- return (
-
-
- {category.name}({category.count})
-
-
- )
- })}
-
-
+
+
+
+ {locale.COMMON.CATEGORY}:
+
+ {categoryOptions?.map(category => {
+ return (
+
+
+ {category.name}(
+ {category.count})
+
+
+ )
+ })}
+
+
+
)
}
@@ -351,30 +405,32 @@ const LayoutTagIndex = props => {
const { tagOptions } = props
const { locale } = useGlobal()
return (
-
-
-
- {locale.COMMON.TAGS}:
-
-
-
+
+
+
+ {locale.COMMON.TAGS}:
+
+
+
)
}
export {
- CONFIG as THEME_CONFIG,
- LayoutBase,
- LayoutIndex,
- LayoutSearch,
- LayoutArchive,
- LayoutSlug,
Layout404,
+ LayoutArchive,
+ LayoutBase,
LayoutCategoryIndex,
+ LayoutIndex,
LayoutPostList,
- LayoutTagIndex
+ LayoutSearch,
+ LayoutSlug,
+ LayoutTagIndex,
+ CONFIG as THEME_CONFIG
}