Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Jun 5, 2024
2 parents b966d2b + b60ad20 commit daafc62
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 19 deletions.
5 changes: 3 additions & 2 deletions blog.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,10 @@ const BLOG = {
'link,wechat,qq,weibo,email,facebook,twitter,telegram,messenger,line,reddit,whatsapp,linkedin', // 分享的服務,按顺序显示,逗号隔开
// 所有支持的分享服务:link(复制链接),wechat(微信),qq,weibo(微博),email(邮件),facebook,twitter,telegram,messenger,line,reddit,whatsapp,linkedin,vkshare,okshare,tumblr,livejournal,mailru,viber,workplace,pocket,instapaper,hatena

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

Expand Down
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const siteConfig = (key, defaultVal = null, extendConfig = {}) => {
return null
}

// 特殊配置处理;某些配置只在服务端生效;而Global的NOTION_CONFIG仅限前端组件使用,因此需要从extendConfig中读取
// 特殊配置处理;以下配置只在服务端生效;而Global的NOTION_CONFIG仅限前端组件使用,因此需要从extendConfig中读取
switch (key) {
case 'NEXT_REVALIDATE_SECOND':
case 'POST_RECOMMEND_COUNT':
Expand Down
2 changes: 1 addition & 1 deletion lib/notion/getPageProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export function adjustPageProperties(properties, NOTION_CONFIG) {
}

// 开启伪静态路径
if (JSON.parse(NOTION_CONFIG?.PSEUDO_STATIC || BLOG.PSEUDO_STATIC)) {
if (siteConfig('PSEUDO_STATIC', false, NOTION_CONFIG)) {
if (
!properties?.href?.endsWith('.html') &&
!properties?.href?.startsWith('http')
Expand Down
4 changes: 2 additions & 2 deletions pages/[prefix]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export async function getStaticProps({ params: { prefix }, locale }) {
let fullSlug = prefix
const from = `slug-props-${fullSlug}`
const props = await getGlobalData({ from, locale })
if (siteConfig('PSEUDO_STATIC', BLOG.PSEUDO_STATIC, props.NOTION_CONFIG)) {
if (siteConfig('PSEUDO_STATIC', false, props.NOTION_CONFIG)) {
if (!fullSlug.endsWith('.html')) {
fullSlug += '.html'
}
Expand All @@ -134,7 +134,7 @@ export async function getStaticProps({ params: { prefix }, locale }) {
props.post = props?.allPages?.find(p => {
return (
p.type.indexOf('Menu') < 0 &&
(p.slug === fullSlug || p.id === idToUuid(fullSlug))
(p.slug === prefix || p.id === idToUuid(prefix))
)
})

Expand Down
4 changes: 2 additions & 2 deletions public/js/fireworks.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ function createFireworks({ config, anime }) {
function updateCoords(e) {
pointerX =
e.clientX ||
(e.touches[0] ? e.touches[0].clientX : e.changedTouches[0].clientX)
(e?.touches[0] ? e.touches[0].clientX : e.changedTouches[0].clientX)
pointerY =
e.clientY ||
(e.touches[0] ? e.touches[0].clientY : e.changedTouches[0].clientY)
(e?.touches[0] ? e.touches[0].clientY : e.changedTouches[0].clientY)
}

function setParticuleDirection(p) {
Expand Down
6 changes: 6 additions & 0 deletions themes/gitbook/components/CatalogDrawerWrapper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useGlobal } from '@/lib/global'
import { useGitBookGlobal } from '@/themes/gitbook'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import Catalog from './Catalog'

/**
Expand All @@ -12,9 +14,13 @@ import Catalog from './Catalog'
const CatalogDrawerWrapper = ({ post, cRef }) => {
const { tocVisible, changeTocVisible } = useGitBookGlobal()
const { locale } = useGlobal()
const router = useRouter()
const switchVisible = () => {
changeTocVisible(!tocVisible)
}
useEffect(() => {
changeTocVisible(false)
}, [router])
return (
<>
<div
Expand Down
8 changes: 7 additions & 1 deletion themes/gitbook/components/PageNavDrawer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useGlobal } from '@/lib/global'
import { useGitBookGlobal } from '@/themes/gitbook'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import NavPostList from './NavPostList'

/**
Expand All @@ -13,11 +15,15 @@ const PageNavDrawer = props => {
const { pageNavVisible, changePageNavVisible } = useGitBookGlobal()
const { filteredNavPages } = props
const { locale } = useGlobal()

const router = useRouter()
const switchVisible = () => {
changePageNavVisible(!pageNavVisible)
}

useEffect(() => {
changePageNavVisible(false)
}, [router])

return (
<>
<div
Expand Down
2 changes: 1 addition & 1 deletion themes/gitbook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ const LayoutBase = props => {
)}
</main>

{/* 移动端底部按钮 */}
{/* 移动端底部导航按钮 */}
<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'>
<div className='w-full'>
<MobileButtonPageNav />
Expand Down
28 changes: 19 additions & 9 deletions themes/hexo/components/PaginationNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const PaginationNumber = ({ page, totalPage }) => {
const pages = generatePages(pagePrefix, page, currentPage, totalPage)

return (
<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'>
<div className='mt-10 mb-5 flex justify-center items-end font-medium text-indigo-400 duration-500 py-3 space-x-2'>
{/* 上一页 */}
<Link
href={{
Expand All @@ -30,7 +30,7 @@ const PaginationNumber = ({ page, totalPage }) => {
query: router.query.s ? { s: router.query.s } : {}
}}
rel='prev'
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`}>
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`}>
<i className='fas fa-angle-left' />
</Link>

Expand All @@ -43,25 +43,35 @@ const PaginationNumber = ({ page, totalPage }) => {
query: router.query.s ? { s: router.query.s } : {}
}}
rel='next'
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`}>
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`}>
<i className='fas fa-angle-right' />
</Link>
</div>
)
}

/**
* 获取页码
* @param {*} page
* @param {*} currentPage
* @param {*} pagePrefix
* @returns
*/
function getPageElement(page, currentPage, pagePrefix) {
const selected = page + '' === currentPage + ''
return (
<Link
href={page === 1 ? `${pagePrefix}/` : `${pagePrefix}/page/${page}`}
key={page}
passHref
className={
(page + '' === currentPage + ''
? 'font-bold bg-indigo-400 dark:bg-indigo-500 text-white '
: 'border-b duration-500 border-indigo-300 hover:border-indigo-400 ') +
' 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'
}>
className={`${
selected
? 'font-bold bg-indigo-400 hover:bg-indigo-600 dark:bg-indigo-500 text-white'
: 'border-b border-indigo-400 text-indigo-400 hover:border-indigo-400 hover:bg-indigo-400'
}
duration-500 hover:font-bold hover:text-white
cursor-pointer pb-0.5 w-6 text-center
`}>
{page}
</Link>
)
Expand Down

0 comments on commit daafc62

Please sign in to comment.