@@ -3,54 +3,131 @@ import Live2D from '@/components/Live2D'
3
3
import Link from 'next/link'
4
4
import React from 'react'
5
5
import BLOG from '@/blog.config'
6
+ import { useGlobal } from '@/lib/global'
6
7
/**
7
8
* 基础布局 采用左右两侧布局,移动端使用顶部导航栏
8
9
9
10
* @returns {JSX.Element }
10
11
* @constructor
11
12
*/
12
13
const LayoutBase = props => {
13
- const { children, meta } = props
14
+ const { children, meta, customNav } = props
15
+ const { locale } = useGlobal ( )
14
16
const d = new Date ( )
15
17
const currentYear = d . getFullYear ( )
16
18
const startYear = BLOG . SINCE && BLOG . SINCE !== currentYear && BLOG . SINCE + '-'
19
+
20
+ let links = [
21
+ { icon : 'fas fa-search' , name : locale . NAV . SEARCH , to : '/search' } ,
22
+ { icon : 'fas fa-archive' , name : locale . NAV . ARCHIVE , to : '/archive' } ,
23
+ { icon : 'fas fa-folder' , name : locale . COMMON . CATEGORY , to : '/category' } ,
24
+ { icon : 'fas fa-tag' , name : locale . COMMON . TAGS , to : '/tag' }
25
+ ]
26
+
27
+ if ( customNav ) {
28
+ links = links . concat ( customNav )
29
+ }
30
+
17
31
return (
18
32
< div >
19
33
< CommonHead meta = { meta } />
20
34
{ /* 导航菜单 */ }
21
35
< div className = "w-full flex justify-center my-2" >
22
- < nav className = "max-w-6xl space-x-3 underline" >
23
- < Link href = "/" >
24
- < a > 首页</ a >
25
- </ Link >
26
- </ nav >
36
+ < div className = " max-w-6xl justify-between w-full flex" >
37
+ < section >
38
+ < Link title = { BLOG . TITLE } href = { '/' } >
39
+ < a className = { 'cursor-pointer flex items-center hover:underline' } >
40
+ < i className = { 'fas fa-home mr-1' } />
41
+ < div className = "text-center" > { BLOG . TITLE } </ div >
42
+ </ a >
43
+ </ Link >
44
+ </ section >
45
+ < nav className = "space-x-3 flex" >
46
+ { links . map ( link => {
47
+ if ( link ) {
48
+ return (
49
+ < Link key = { `${ link . to } ` } title = { link . to } href = { link . to } >
50
+ < a
51
+ className = {
52
+ 'cursor-pointer flex items-center hover:underline'
53
+ }
54
+ >
55
+ < i className = { `${ link . icon } mr-1` } />
56
+ < div className = "text-center" > { link . name } </ div >
57
+ </ a >
58
+ </ Link >
59
+ )
60
+ } else {
61
+ return null
62
+ }
63
+ } ) }
64
+ </ nav >
65
+ </ div >
27
66
</ div >
67
+
28
68
{ /* 内容主体 */ }
29
69
< main id = "wrapper" className = "flex justify-center flex-1 pb-12" >
30
- < div className = "max-w-4xl px-3" > { children } </ div >
31
- < div >
32
- < div className = ' sticky top-0 z-40' >
33
- < Live2D />
70
+ < div className = "max-w-4xl w-full px-3" > { children } </ div >
71
+ < div >
72
+ < div className = " sticky top-0 z-40" >
73
+ < Live2D />
34
74
</ div >
35
75
</ div >
36
76
</ main >
37
- < footer
38
- className = 'font-sans dark:bg-gray-900 flex-shrink-0 justify-center text-center m-auto w-full leading-6 text-sm p-6'
39
- >
40
- < i className = 'fas fa-copyright' /> { `${ startYear } ${ currentYear } ` } < span > < i className = 'mx-1 animate-pulse fas fa-heart' /> < a href = { BLOG . LINK } className = 'underline font-bold dark:text-gray-300 ' > { BLOG . AUTHOR } </ a > .
41
- < br />
42
-
43
- < span > Powered by < a href = 'https://notion.so' className = 'underline font-bold dark:text-gray-300' > Notion</ a > & < a href = 'https://github.com/tangly1024/NotionNext' className = 'underline font-bold dark:text-gray-300' > NotionNext { BLOG . VERSION } </ a > .</ span > </ span >
44
77
45
- { BLOG . BEI_AN && < > < br /> < i className = 'fas fa-shield-alt' /> < a href = 'https://beian.miit.gov.cn/' className = 'mr-2' > { BLOG . BEI_AN } </ a > < br /> </ > }
46
- < br />
47
- < span className = 'hidden busuanzi_container_site_pv' >
48
- < i className = 'fas fa-eye' /> < span className = 'px-1 busuanzi_value_site_pv' > </ span > </ span >
49
- < span className = 'pl-2 hidden busuanzi_container_site_uv' >
50
- < i className = 'fas fa-users' /> < span className = 'px-1 busuanzi_value_site_uv' > </ span > </ span >
51
- < br />
78
+ { /* 页脚 */ }
79
+ < footer className = "font-sans dark:bg-gray-900 flex-shrink-0 justify-center text-center m-auto w-full leading-6 text-sm p-6" >
80
+ < i className = "fas fa-copyright" /> { `${ startYear } ${ currentYear } ` } { ' ' }
81
+ < span >
82
+ < i className = "mx-1 animate-pulse fas fa-heart" /> { ' ' }
83
+ < a
84
+ href = { BLOG . LINK }
85
+ className = "underline font-bold dark:text-gray-300 "
86
+ >
87
+ { BLOG . AUTHOR }
88
+ </ a >
89
+ .
90
+ < br />
91
+ < span >
92
+ Powered by{ ' ' }
93
+ < a
94
+ href = "https://notion.so"
95
+ className = "underline font-bold dark:text-gray-300"
96
+ >
97
+ Notion
98
+ </ a > { ' ' }
99
+ & { ' ' }
100
+ < a
101
+ href = "https://github.com/tangly1024/NotionNext"
102
+ className = "underline font-bold dark:text-gray-300"
103
+ >
104
+ NotionNext { BLOG . VERSION }
105
+ </ a >
106
+ .
107
+ </ span >
108
+ </ span >
109
+ { BLOG . BEI_AN && (
110
+ < >
111
+ < br />
112
+ < i className = "fas fa-shield-alt" /> { ' ' }
113
+ < a href = "https://beian.miit.gov.cn/" className = "mr-2" >
114
+ { BLOG . BEI_AN }
115
+ </ a >
116
+ < br />
117
+ </ >
118
+ ) }
119
+ < br />
120
+ < span className = "hidden busuanzi_container_site_pv" >
121
+ < i className = "fas fa-eye" />
122
+ < span className = "px-1 busuanzi_value_site_pv" > </ span > { ' ' }
123
+ </ span >
124
+ < span className = "pl-2 hidden busuanzi_container_site_uv" >
125
+ < i className = "fas fa-users" /> { ' ' }
126
+ < span className = "px-1 busuanzi_value_site_uv" > </ span > { ' ' }
127
+ </ span >
128
+ < br />
52
129
< h1 > { meta ?. title || BLOG . TITLE } </ h1 >
53
- </ footer >
130
+ </ footer >
54
131
</ div >
55
132
)
56
133
}
0 commit comments