Skip to content

Commit 41511cf

Browse files
committed
2 parents 269ae1b + b60ad20 commit 41511cf

File tree

9 files changed

+42
-19
lines changed

9 files changed

+42
-19
lines changed

blog.config.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,10 @@ const BLOG = {
196196
POSTS_SHARE_SERVICES: process.env.NEXT_PUBLIC_POST_SHARE_SERVICES || 'link,weibo,wechat,qq,twitter,facebook,reddit,linkedin,telegram,line', // 分享的服務,按顺序显示,逗号隔开
197197
// 所有支持的分享服务:link(复制链接),wechat(微信),qq,weibo(微博),email(邮件),facebook,twitter,telegram,messenger,line,reddit,whatsapp,linkedin,vkshare,okshare,tumblr,livejournal,mailru,viber,workplace,pocket,instapaper,hatena
198198

199-
POST_URL_PREFIX: process.env.NEXT_PUBLIC_POST_URL_PREFIX || 'article',
199+
// 文章URL前缀
200+
POST_URL_PREFIX: process.env.NEXT_PUBLIC_POST_URL_PREFIX ?? 'article',
200201
// POST类型文章的默认路径前缀,例如默认POST类型的路径是 /article/[slug]
201-
// 如果此项配置为 '' 空, 则文章将没有前缀路径,使用场景: 希望文章前缀路径为 /post 的情况 支持多级
202+
// 如果此项配置为 '' 空, 则文章将没有前缀路径
202203
// 支援類似 WP 可自訂文章連結格式的功能:https://wordpress.org/documentation/article/customize-permalinks/,目前只先實作 %year%/%month%/%day%
203204
// 例:如想連結改成前綴 article + 時間戳記,可變更為: 'article/%year%/%month%/%day%'
204205

lib/config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const siteConfig = (key, defaultVal = null, extendConfig = {}) => {
1919
return null
2020
}
2121

22-
// 特殊配置处理;某些配置只在服务端生效;而Global的NOTION_CONFIG仅限前端组件使用,因此需要从extendConfig中读取
22+
// 特殊配置处理;以下配置只在服务端生效;而Global的NOTION_CONFIG仅限前端组件使用,因此需要从extendConfig中读取
2323
switch (key) {
2424
case 'NEXT_REVALIDATE_SECOND':
2525
case 'POST_RECOMMEND_COUNT':

lib/notion/getPageProperties.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export function adjustPageProperties(properties, NOTION_CONFIG) {
187187
}
188188

189189
// 开启伪静态路径
190-
if (JSON.parse(NOTION_CONFIG?.PSEUDO_STATIC || BLOG.PSEUDO_STATIC)) {
190+
if (siteConfig('PSEUDO_STATIC', false, NOTION_CONFIG)) {
191191
if (
192192
!properties?.href?.endsWith('.html') &&
193193
!properties?.href?.startsWith('http')

pages/[prefix]/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export async function getStaticProps({ params: { prefix }, locale }) {
124124
let fullSlug = prefix
125125
const from = `slug-props-${fullSlug}`
126126
const props = await getGlobalData({ from, locale })
127-
if (siteConfig('PSEUDO_STATIC', BLOG.PSEUDO_STATIC, props.NOTION_CONFIG)) {
127+
if (siteConfig('PSEUDO_STATIC', false, props.NOTION_CONFIG)) {
128128
if (!fullSlug.endsWith('.html')) {
129129
fullSlug += '.html'
130130
}
@@ -134,7 +134,7 @@ export async function getStaticProps({ params: { prefix }, locale }) {
134134
props.post = props?.allPages?.find(p => {
135135
return (
136136
p.type.indexOf('Menu') < 0 &&
137-
(p.slug === fullSlug || p.id === idToUuid(fullSlug))
137+
(p.slug === prefix || p.id === idToUuid(prefix))
138138
)
139139
})
140140

public/js/fireworks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ function createFireworks({ config, anime }) {
5757
function updateCoords(e) {
5858
pointerX =
5959
e.clientX ||
60-
(e.touches[0] ? e.touches[0].clientX : e.changedTouches[0].clientX)
60+
(e?.touches[0] ? e.touches[0].clientX : e.changedTouches[0].clientX)
6161
pointerY =
6262
e.clientY ||
63-
(e.touches[0] ? e.touches[0].clientY : e.changedTouches[0].clientY)
63+
(e?.touches[0] ? e.touches[0].clientY : e.changedTouches[0].clientY)
6464
}
6565

6666
function setParticuleDirection(p) {

themes/gitbook/components/CatalogDrawerWrapper.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { useGlobal } from '@/lib/global'
22
import { useGitBookGlobal } from '@/themes/gitbook'
3+
import { useRouter } from 'next/router'
4+
import { useEffect } from 'react'
35
import Catalog from './Catalog'
46

57
/**
@@ -12,9 +14,13 @@ import Catalog from './Catalog'
1214
const CatalogDrawerWrapper = ({ post, cRef }) => {
1315
const { tocVisible, changeTocVisible } = useGitBookGlobal()
1416
const { locale } = useGlobal()
17+
const router = useRouter()
1518
const switchVisible = () => {
1619
changeTocVisible(!tocVisible)
1720
}
21+
useEffect(() => {
22+
changeTocVisible(false)
23+
}, [router])
1824
return (
1925
<>
2026
<div

themes/gitbook/components/PageNavDrawer.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { useGlobal } from '@/lib/global'
22
import { useGitBookGlobal } from '@/themes/gitbook'
3+
import { useRouter } from 'next/router'
4+
import { useEffect } from 'react'
35
import NavPostList from './NavPostList'
46

57
/**
@@ -13,11 +15,15 @@ const PageNavDrawer = props => {
1315
const { pageNavVisible, changePageNavVisible } = useGitBookGlobal()
1416
const { filteredNavPages } = props
1517
const { locale } = useGlobal()
16-
18+
const router = useRouter()
1719
const switchVisible = () => {
1820
changePageNavVisible(!pageNavVisible)
1921
}
2022

23+
useEffect(() => {
24+
changePageNavVisible(false)
25+
}, [router])
26+
2127
return (
2228
<>
2329
<div

themes/gitbook/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ const LayoutBase = props => {
239239
)}
240240
</main>
241241

242-
{/* 移动端底部按钮 */}
242+
{/* 移动端底部导航按钮 */}
243243
<div className='bottom-button-group md:hidden w-screen h-12 px-4 fixed flex items-center justify-between right-0 bottom-0 z-30 bg-white border-l border-t dark:border-gray-800'>
244244
<div className='w-full'>
245245
<MobileButtonPageNav />

themes/hexo/components/PaginationNumber.js

+19-9
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const PaginationNumber = ({ page, totalPage }) => {
1919
const pages = generatePages(pagePrefix, page, currentPage, totalPage)
2020

2121
return (
22-
<div className='mt-10 mb-5 flex justify-center items-end font-medium text-black duration-500 dark:text-gray-300 py-3 space-x-2'>
22+
<div className='mt-10 mb-5 flex justify-center items-end font-medium text-indigo-400 duration-500 py-3 space-x-2'>
2323
{/* 上一页 */}
2424
<Link
2525
href={{
@@ -30,7 +30,7 @@ const PaginationNumber = ({ page, totalPage }) => {
3030
query: router.query.s ? { s: router.query.s } : {}
3131
}}
3232
rel='prev'
33-
className={`${currentPage === 1 ? 'invisible' : 'block'} pb-0.5 border-white dark:border-indigo-700 hover:border-indigo-400 dark:hover:border-indigo-400 w-6 text-center cursor-pointer duration-200 hover:font-bold`}>
33+
className={`${currentPage === 1 ? 'invisible' : 'block'} pb-0.5 hover:bg-indigo-400 hover:text-white w-6 text-center cursor-pointer duration-200 hover:font-bold`}>
3434
<i className='fas fa-angle-left' />
3535
</Link>
3636

@@ -43,25 +43,35 @@ const PaginationNumber = ({ page, totalPage }) => {
4343
query: router.query.s ? { s: router.query.s } : {}
4444
}}
4545
rel='next'
46-
className={`${+showNext ? 'block' : 'invisible'} pb-0.5 border-b border-indigo-300 dark:border-indigo-700 hover:border-indigo-400 dark:hover:border-indigo-400 w-6 text-center cursor-pointer duration-500 hover:font-bold`}>
46+
className={`${+showNext ? 'block' : 'invisible'} pb-0.5 hover:bg-indigo-400 hover:text-white w-6 text-center cursor-pointer duration-200 hover:font-bold`}>
4747
<i className='fas fa-angle-right' />
4848
</Link>
4949
</div>
5050
)
5151
}
5252

53+
/**
54+
* 获取页码
55+
* @param {*} page
56+
* @param {*} currentPage
57+
* @param {*} pagePrefix
58+
* @returns
59+
*/
5360
function getPageElement(page, currentPage, pagePrefix) {
61+
const selected = page + '' === currentPage + ''
5462
return (
5563
<Link
5664
href={page === 1 ? `${pagePrefix}/` : `${pagePrefix}/page/${page}`}
5765
key={page}
5866
passHref
59-
className={
60-
(page + '' === currentPage + ''
61-
? 'font-bold bg-indigo-400 dark:bg-indigo-500 text-white '
62-
: 'border-b duration-500 border-indigo-300 hover:border-indigo-400 ') +
63-
' border-white dark:border-indigo-700 dark:hover:border-indigo-400 cursor-pointer pb-0.5 w-6 text-center font-light hover:font-bold'
64-
}>
67+
className={`${
68+
selected
69+
? 'font-bold bg-indigo-400 hover:bg-indigo-600 dark:bg-indigo-500 text-white'
70+
: 'border-b border-indigo-400 text-indigo-400 hover:border-indigo-400 hover:bg-indigo-400'
71+
}
72+
duration-500 hover:font-bold hover:text-white
73+
cursor-pointer pb-0.5 w-6 text-center
74+
`}>
6575
{page}
6676
</Link>
6777
)

0 commit comments

Comments
 (0)