Skip to content

Commit 14e9ed1

Browse files
committed
2 parents 77a8e99 + 96d5e2e commit 14e9ed1

File tree

6 files changed

+196
-39
lines changed

6 files changed

+196
-39
lines changed

lib/db/getSiteData.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import getAllPageIds from '@/lib/notion/getAllPageIds'
55
import { getAllTags } from '@/lib/notion/getAllTags'
66
import { getConfigMapFromConfigPage } from '@/lib/notion/getNotionConfig'
77
import getPageProperties, {
8-
adjustPageProperties
8+
adjustPageProperties
99
} from '@/lib/notion/getPageProperties'
1010
import { fetchInBatches, getPage } from '@/lib/notion/getPostBlocks'
1111
import { compressImage, mapImgUrl } from '@/lib/notion/mapImage'
@@ -512,6 +512,7 @@ async function getDataBaseInfoByNotionAPI({ pageId, from }) {
512512
adjustPageProperties(element, NOTION_CONFIG)
513513
})
514514

515+
// 站点基础信息
515516
const siteInfo = getSiteInfo({ collection, block, pageId })
516517

517518
// 文章计数

next.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ const locales = (function () {
3232
return langs
3333
})()
3434

35+
// 编译前执行
36+
const preBuild = (function () {
37+
// 删除 public/sitemap.xml 文件 ; 否则会和/pages/sitemap.xml.js 冲突。
38+
const sitemapPath = path.resolve(__dirname, 'public', 'sitemap.xml')
39+
if (fs.existsSync(sitemapPath)) {
40+
fs.unlinkSync(sitemapPath)
41+
console.log('Deleted existing sitemap.xml from public directory')
42+
}
43+
})()
44+
3545
/**
3646
* 扫描指定目录下的文件夹名,用于获取所有主题
3747
* @param {*} directory

pages/[prefix]/[slug]/[...suffix].js

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ export async function getStaticPaths() {
3030

3131
const from = 'slug-paths'
3232
const { allPages } = await getGlobalData({ from })
33-
33+
const paths = allPages
34+
?.filter(row => checkSlugHasMorThanTwoSlash(row))
35+
.map(row => ({
36+
params: {
37+
prefix: row.slug.split('/')[0],
38+
slug: row.slug.split('/')[1],
39+
suffix: row.slug.split('/').slice(2)
40+
}
41+
}))
3442
return {
35-
paths: allPages
36-
?.filter(row => checkSlugHasMorThanTwoSlash(row))
37-
.map(row => ({
38-
params: {
39-
prefix: row.slug.split('/')[0],
40-
slug: row.slug.split('/')[1],
41-
suffix: row.slug.split('/').slice(1)
42-
}
43-
})),
43+
paths: paths,
4444
fallback: true
4545
}
4646
}

themes/example/components/BlogListPage.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ export const BlogListPage = props => {
4545
: `${pagePrefix}/page/${currentPage - 1}`,
4646
query: router.query.s ? { s: router.query.s } : {}
4747
}}
48-
className={`${showPrev ? 'bg-black ' : 'bg-gray pointer-events-none '} text-white no-underline py-2 px-3 rounded`}>
48+
className={`${showPrev ? 'bg-black dark:bg-hexo-black-gray' : 'bg-gray pointer-events-none invisible'} text-white no-underline py-2 px-3 rounded`}>
4949
{locale.PAGINATION.PREV}
5050
</Link>
5151
<Link
5252
href={{
5353
pathname: `${pagePrefix}/page/${currentPage + 1}`,
5454
query: router.query.s ? { s: router.query.s } : {}
5555
}}
56-
className={`${showNext ? 'bg-black ' : 'bg-gray pointer-events-none '} text-white no-underline py-2 px-3 rounded`}>
56+
className={`${showNext ? 'bg-black dark:bg-hexo-black-gray ' : 'bg-gray pointer-events-none invisible'} text-white no-underline py-2 px-3 rounded`}>
5757
{locale.PAGINATION.NEXT}
5858
</Link>
5959
</div>

themes/gitbook/components/Footer.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { siteConfig } from '@/lib/config'
2+
import SocialButton from './SocialButton'
23

34
const Footer = ({ siteInfo }) => {
45
const d = new Date()
@@ -11,7 +12,9 @@ const Footer = ({ siteInfo }) => {
1112
<footer className='z-20 bg:white dark:bg-hexo-black-gray justify-center text-center w-full text-sm relative'>
1213
<hr className='pb-2' />
1314

14-
<div className='flex justify-center'>
15+
<SocialButton />
16+
17+
<div className='flex justify-center pt-1'>
1518
<div>
1619
<i className='mx-1 animate-pulse fas fa-heart' />{' '}
1720
<a
+168-25
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,179 @@
1+
import QrCode from '@/components/QrCode'
12
import { siteConfig } from '@/lib/config'
3+
import { useState } from 'react'
24

35
/**
46
* 社交联系方式按钮组
57
* @returns {JSX.Element}
68
* @constructor
79
*/
810
const SocialButton = () => {
9-
return <div className='space-x-3 text-xl text-gray-600 dark:text-gray-400 flex-wrap flex justify-center '>
10-
{siteConfig('CONTACT_GITHUB') && <a target='_blank' rel='noreferrer' title={'github'} href={siteConfig('CONTACT_GITHUB')} >
11-
<i className='fab fa-github transform hover:scale-125 duration-150 hover:text-green-600'/>
12-
</a>}
13-
{siteConfig('CONTACT_TWITTER') && <a target='_blank' rel='noreferrer' title={'twitter'} href={siteConfig('CONTACT_TWITTER')} >
14-
<i className='fab fa-twitter transform hover:scale-125 duration-150 hover:text-green-600'/>
15-
</a>}
16-
{siteConfig('CONTACT_TELEGRAM') && <a target='_blank' rel='noreferrer' href={siteConfig('CONTACT_TELEGRAM')} title={'telegram'} >
17-
<i className='fab fa-telegram transform hover:scale-125 duration-150 hover:text-green-600'/>
18-
</a>}
19-
{siteConfig('CONTACT_LINKEDIN') && <a target='_blank' rel='noreferrer' href={siteConfig('CONTACT_LINKEDIN')} title={'linkedIn'} >
20-
<i className='transform hover:scale-125 duration-150 fab fa-linkedin dark:hover:text-indigo-400 hover:text-indigo-600'/>
21-
</a>}
22-
{siteConfig('CONTACT_WEIBO') && <a target='_blank' rel='noreferrer' title={'weibo'} href={siteConfig('CONTACT_WEIBO')} >
23-
<i className='fab fa-weibo transform hover:scale-125 duration-150 hover:text-green-600'/>
24-
</a>}
25-
{siteConfig('CONTACT_INSTAGRAM') && <a target='_blank' rel='noreferrer' title={'instagram'} href={siteConfig('CONTACT_INSTAGRAM')} >
26-
<i className='fab fa-instagram transform hover:scale-125 duration-150 hover:text-green-600'/>
27-
</a>}
28-
{siteConfig('CONTACT_EMAIL') && <a target='_blank' rel='noreferrer' title={'email'} href={`mailto:${siteConfig('CONTACT_EMAIL')}`} >
29-
<i className='fas fa-envelope transform hover:scale-125 duration-150 hover:text-green-600'/>
30-
</a>}
31-
{JSON.parse(siteConfig('ENABLE_RSS')) && <a target='_blank' rel='noreferrer' title={'RSS'} href={'/feed'} >
32-
<i className='fas fa-rss transform hover:scale-125 duration-150 hover:text-green-600'/>
33-
</a>}
11+
const CONTACT_GITHUB = siteConfig('CONTACT_GITHUB')
12+
const CONTACT_TWITTER = siteConfig('CONTACT_TWITTER')
13+
const CONTACT_TELEGRAM = siteConfig('CONTACT_TELEGRAM')
14+
15+
const CONTACT_LINKEDIN = siteConfig('CONTACT_LINKEDIN')
16+
const CONTACT_WEIBO = siteConfig('CONTACT_WEIBO')
17+
const CONTACT_INSTAGRAM = siteConfig('CONTACT_INSTAGRAM')
18+
const CONTACT_EMAIL = siteConfig('CONTACT_EMAIL')
19+
const ENABLE_RSS = siteConfig('ENABLE_RSS')
20+
const CONTACT_BILIBILI = siteConfig('CONTACT_BILIBILI')
21+
const CONTACT_YOUTUBE = siteConfig('CONTACT_YOUTUBE')
22+
23+
const CONTACT_XIAOHONGSHU = siteConfig('CONTACT_XIAOHONGSHU')
24+
const CONTACT_ZHISHIXINGQIU = siteConfig('CONTACT_ZHISHIXINGQIU')
25+
const CONTACT_WEHCHAT_PUBLIC = siteConfig('CONTACT_WEHCHAT_PUBLIC')
26+
const [qrCodeShow, setQrCodeShow] = useState(false)
27+
28+
const openPopover = () => {
29+
setQrCodeShow(true)
30+
}
31+
const closePopover = () => {
32+
setQrCodeShow(false)
33+
}
34+
35+
return (
36+
<div className='w-full justify-center flex-wrap flex'>
37+
<div className='space-x-3 text-xl flex items-center text-gray-600 dark:text-gray-300 '>
38+
{CONTACT_GITHUB && (
39+
<a
40+
target='_blank'
41+
rel='noreferrer'
42+
title={'github'}
43+
href={CONTACT_GITHUB}>
44+
<i className='transform hover:scale-125 duration-150 fab fa-github dark:hover:text-green-400 hover:text-green-600' />
45+
</a>
46+
)}
47+
{CONTACT_TWITTER && (
48+
<a
49+
target='_blank'
50+
rel='noreferrer'
51+
title={'twitter'}
52+
href={CONTACT_TWITTER}>
53+
<i className='transform hover:scale-125 duration-150 fab fa-twitter dark:hover:text-green-400 hover:text-green-600' />
54+
</a>
55+
)}
56+
{CONTACT_TELEGRAM && (
57+
<a
58+
target='_blank'
59+
rel='noreferrer'
60+
href={CONTACT_TELEGRAM}
61+
title={'telegram'}>
62+
<i className='transform hover:scale-125 duration-150 fab fa-telegram dark:hover:text-green-400 hover:text-green-600' />
63+
</a>
64+
)}
65+
{CONTACT_LINKEDIN && (
66+
<a
67+
target='_blank'
68+
rel='noreferrer'
69+
href={CONTACT_LINKEDIN}
70+
title={'linkIn'}>
71+
<i className='transform hover:scale-125 duration-150 fab fa-linkedin dark:hover:text-green-400 hover:text-green-600' />
72+
</a>
73+
)}
74+
{CONTACT_WEIBO && (
75+
<a
76+
target='_blank'
77+
rel='noreferrer'
78+
title={'weibo'}
79+
href={CONTACT_WEIBO}>
80+
<i className='transform hover:scale-125 duration-150 fab fa-weibo dark:hover:text-green-400 hover:text-green-600' />
81+
</a>
82+
)}
83+
{CONTACT_INSTAGRAM && (
84+
<a
85+
target='_blank'
86+
rel='noreferrer'
87+
title={'instagram'}
88+
href={CONTACT_INSTAGRAM}>
89+
<i className='transform hover:scale-125 duration-150 fab fa-instagram dark:hover:text-green-400 hover:text-green-600' />
90+
</a>
91+
)}
92+
{CONTACT_EMAIL && (
93+
<a
94+
target='_blank'
95+
rel='noreferrer'
96+
title={'email'}
97+
href={`mailto:${CONTACT_EMAIL}`}>
98+
<i className='transform hover:scale-125 duration-150 fas fa-envelope dark:hover:text-green-400 hover:text-green-600' />
99+
</a>
100+
)}
101+
{ENABLE_RSS && (
102+
<a target='_blank' rel='noreferrer' title={'RSS'} href={'/feed'}>
103+
<i className='transform hover:scale-125 duration-150 fas fa-rss dark:hover:text-green-400 hover:text-green-600' />
104+
</a>
105+
)}
106+
{CONTACT_BILIBILI && (
107+
<a
108+
target='_blank'
109+
rel='noreferrer'
110+
title={'bilibili'}
111+
href={CONTACT_BILIBILI}>
112+
<i className='transform hover:scale-125 duration-150 dark:hover:text-green-400 hover:text-green-600 fab fa-bilibili' />
113+
</a>
114+
)}
115+
{CONTACT_YOUTUBE && (
116+
<a
117+
target='_blank'
118+
rel='noreferrer'
119+
title={'youtube'}
120+
href={CONTACT_YOUTUBE}>
121+
<i className='transform hover:scale-125 duration-150 fab fa-youtube dark:hover:text-green-400 hover:text-green-600' />
122+
</a>
123+
)}
124+
{CONTACT_XIAOHONGSHU && (
125+
<a
126+
target='_blank'
127+
rel='noreferrer'
128+
title={'小红书'}
129+
href={CONTACT_XIAOHONGSHU}>
130+
{/* eslint-disable-next-line @next/next/no-img-element */}
131+
<img
132+
className='transform hover:scale-125 duration-150 w-6'
133+
src='/svg/xiaohongshu.svg'
134+
alt='小红书'
135+
/>
136+
</a>
137+
)}
138+
{CONTACT_ZHISHIXINGQIU && (
139+
<a
140+
target='_blank'
141+
rel='noreferrer'
142+
title={'知识星球'}
143+
href={CONTACT_ZHISHIXINGQIU}>
144+
{/* eslint-disable-next-line @next/next/no-img-element */}
145+
<img
146+
className='transform hover:scale-125 duration-150 w-6'
147+
src='/svg/zhishixingqiu.svg'
148+
alt='知识星球'
149+
/>{' '}
150+
</a>
151+
)}
152+
{CONTACT_WEHCHAT_PUBLIC && (
153+
<button
154+
onMouseEnter={openPopover}
155+
onMouseLeave={closePopover}
156+
aria-label={'微信公众号'}>
157+
<div id='wechat-button'>
158+
<i className='transform scale-105 hover:scale-125 duration-150 fab fa-weixin dark:hover:text-green-400 hover:text-green-600' />
159+
</div>
160+
{/* 二维码弹框 */}
161+
<div className='absolute'>
162+
<div
163+
id='pop'
164+
className={
165+
(qrCodeShow ? 'opacity-100 ' : ' invisible opacity-0') +
166+
' z-40 absolute bottom-10 -left-10 bg-white shadow-xl transition-all duration-200 text-center'
167+
}>
168+
<div className='p-2 mt-1 w-28 h-28'>
169+
{qrCodeShow && <QrCode value={CONTACT_WEHCHAT_PUBLIC} />}
170+
</div>
171+
</div>
172+
</div>
173+
</button>
174+
)}
175+
</div>
34176
</div>
177+
)
35178
}
36179
export default SocialButton

0 commit comments

Comments
 (0)