1
1
import CONFIG from './config'
2
2
3
- import { useEffect , useRef } from 'react'
4
- import Footer from './components/Footer'
3
+ import LazyImage from '@/components/LazyImage'
4
+ import replaceSearchResult from '@/components/Mark'
5
+ import NotionPage from '@/components/NotionPage'
6
+ import { siteConfig } from '@/lib/config'
5
7
import { useGlobal } from '@/lib/global'
6
8
import { isBrowser , scanAndConvertToLinks } from '@/lib/utils'
9
+ import { Transition } from '@headlessui/react'
10
+ import Link from 'next/link'
11
+ import { useRouter } from 'next/router'
12
+ import { useEffect , useRef } from 'react'
13
+ import { ArticleLock } from './components/ArticleLock'
14
+ import BlogPostArchive from './components/BlogPostArchive'
7
15
import BlogPostListPage from './components/BlogPostListPage'
8
16
import BlogPostListScroll from './components/BlogPostListScroll'
9
- import Hero from './components/Hero'
10
- import { useRouter } from 'next/router'
11
17
import Card from './components/Card'
18
+ import Footer from './components/Footer'
19
+ import Header from './components/Header'
20
+ import Hero from './components/Hero'
21
+ import PostHeader from './components/PostHeader'
22
+ import ProductCategories from './components/ProductCategories'
23
+ import ProductCenter from './components/ProductCenter'
12
24
import RightFloatArea from './components/RightFloatArea'
13
25
import SearchNav from './components/SearchNav'
14
- import BlogPostArchive from './components/BlogPostArchive'
15
- import { ArticleLock } from './components/ArticleLock'
16
- import PostHeader from './components/PostHeader'
17
- import TocDrawer from './components/TocDrawer'
18
- import NotionPage from '@/components/NotionPage'
19
- import TagItemMini from './components/TagItemMini'
20
- import Link from 'next/link'
21
26
import SlotBar from './components/SlotBar'
22
- import { Transition } from '@headlessui/react'
27
+ import TagItemMini from './components/TagItemMini'
28
+ import TocDrawer from './components/TocDrawer'
23
29
import { Style } from './style'
24
- import replaceSearchResult from '@/components/Mark'
25
- import { siteConfig } from '@/lib/config'
26
- import Header from './components/Header'
27
- import ProductCenter from './components/ProductCenter'
28
- import LazyImage from '@/components/LazyImage'
29
- import ProductCategories from './components/ProductCategories'
30
30
31
31
/**
32
32
* 基础布局 采用左右两侧布局,移动端使用顶部导航栏
@@ -35,17 +35,19 @@ import ProductCategories from './components/ProductCategories'
35
35
* @constructor
36
36
*/
37
37
const LayoutBase = props => {
38
- const { children, post, floatSlot, slotTop, slotRight, meta, className } =
39
- props
38
+ const { children, post, floatSlot, slotTop, className } = props
40
39
const { onLoading } = useGlobal ( )
41
-
40
+ const router = useRouter ( )
42
41
// 查找页面上的 链接,并便成为可点击
43
42
useEffect ( ( ) => {
44
43
scanAndConvertToLinks ( document . getElementById ( 'theme-commerce' ) )
45
- } )
44
+ } , [ router ] )
45
+
46
+ const slotRight = router . route !== '/' && ! post && (
47
+ < ProductCategories { ...props } />
48
+ )
46
49
47
50
let headerSlot = null
48
- const router = useRouter ( )
49
51
if ( router . route === '/' && ! post ) {
50
52
headerSlot = JSON . parse ( siteConfig ( 'COMMERCE_HOME_BANNER_ENABLE' , true ) ) ? (
51
53
< Hero { ...props } />
@@ -146,18 +148,15 @@ const LayoutIndex = props => {
146
148
* @returns
147
149
*/
148
150
const LayoutPostList = props => {
149
- const slotRight = < ProductCategories { ...props } />
150
151
return (
151
- < LayoutBase { ...props } slotRight = { slotRight } >
152
- < div className = 'bg-white border-[#D2232A] p-4' >
153
- < SlotBar { ...props } />
154
- { siteConfig ( 'POST_LIST_STYLE' ) === 'page' ? (
155
- < BlogPostListPage { ...props } />
156
- ) : (
157
- < BlogPostListScroll { ...props } />
158
- ) }
159
- </ div >
160
- </ LayoutBase >
152
+ < div className = 'bg-white border-[#D2232A] p-4' >
153
+ < SlotBar { ...props } />
154
+ { siteConfig ( 'POST_LIST_STYLE' ) === 'page' ? (
155
+ < BlogPostListPage { ...props } />
156
+ ) : (
157
+ < BlogPostListScroll { ...props } />
158
+ ) }
159
+ </ div >
161
160
)
162
161
}
163
162
@@ -241,7 +240,6 @@ const LayoutSlug = props => {
241
240
const headerImage = post ?. pageCover
242
241
? post . pageCover
243
242
: siteConfig ( 'HOME_BANNER_IMAGE' )
244
- const floatSlot = < > </ >
245
243
246
244
return (
247
245
< >
@@ -395,14 +393,14 @@ const LayoutTagIndex = props => {
395
393
}
396
394
397
395
export {
398
- CONFIG as THEME_CONFIG ,
396
+ Layout404 ,
397
+ LayoutArchive ,
399
398
LayoutBase ,
399
+ LayoutCategoryIndex ,
400
400
LayoutIndex ,
401
+ LayoutPostList ,
401
402
LayoutSearch ,
402
- LayoutArchive ,
403
403
LayoutSlug ,
404
- Layout404 ,
405
- LayoutCategoryIndex ,
406
- LayoutPostList ,
407
- LayoutTagIndex
404
+ LayoutTagIndex ,
405
+ CONFIG as THEME_CONFIG
408
406
}
0 commit comments