diff --git a/lib/lang/en-US.js b/lib/lang/en-US.js index 6b40a44c..d2b5e232 100644 --- a/lib/lang/en-US.js +++ b/lib/lang/en-US.js @@ -66,7 +66,8 @@ export default { MINUTE: 'min', WORD_COUNT: 'Words', READ_TIME: 'Read Time', - NEXT_POST: '下一篇' + NEXT_POST: 'Next', + PREV_POST: 'Prev' }, PAGINATION: { PREV: 'Prev', diff --git a/lib/lang/zh-CN.js b/lib/lang/zh-CN.js index c49ed544..0d206d5a 100644 --- a/lib/lang/zh-CN.js +++ b/lib/lang/zh-CN.js @@ -66,7 +66,8 @@ export default { MINUTE: '分钟', WORD_COUNT: '字数', READ_TIME: '阅读时长', - NEXT_POST: '下一篇' + NEXT_POST: '下一篇', + PREV_POST: '上一篇' }, PAGINATION: { PREV: '上页', diff --git a/lib/lang/zh-HK.js b/lib/lang/zh-HK.js index 6e9df618..e4de0f4e 100644 --- a/lib/lang/zh-HK.js +++ b/lib/lang/zh-HK.js @@ -37,7 +37,9 @@ export default { ARTICLE_LOCK_TIPS: '文章已上鎖,請輸入訪問密碼', SUBMIT: '提交', POST_TIME: '发布于', - LAST_EDITED_TIME: '最后更新' + LAST_EDITED_TIME: '最后更新', + NEXT_POST: '下一篇', + PREV_POST: '上一篇' }, PAGINATION: { PREV: '上一頁', diff --git a/lib/lang/zh-TW.js b/lib/lang/zh-TW.js index 1fe2dbb1..02c3ed2f 100644 --- a/lib/lang/zh-TW.js +++ b/lib/lang/zh-TW.js @@ -37,7 +37,9 @@ export default { ARTICLE_LOCK_TIPS: '文章已上鎖,請輸入訪問密碼', SUBMIT: '提交', POST_TIME: '发布于', - LAST_EDITED_TIME: '最后更新' + LAST_EDITED_TIME: '最后更新', + NEXT_POST: '下一篇', + PREV_POST: '上一篇' }, PAGINATION: { PREV: '上一頁', diff --git a/themes/gitbook/components/ArticleAround.js b/themes/gitbook/components/ArticleAround.js index 58069682..56db04ea 100644 --- a/themes/gitbook/components/ArticleAround.js +++ b/themes/gitbook/components/ArticleAround.js @@ -1,3 +1,4 @@ +import { useGlobal } from '@/lib/global' import Link from 'next/link' /** @@ -9,21 +10,29 @@ export default function ArticleAround({ prev, next }) { if (!prev || !next) { return <> } + const { locale } = useGlobal() return ( -
+
- - {prev.title} + className='rounded border w-full h-20 px-3 cursor-pointer justify-between items-center flex hover:text-green-500 duration-300'> + +
+
{locale.COMMON.PREV_POST}
+
{prev.title}
+
+ - {next.title} - + className='rounded border w-full h-20 px-3 cursor-pointer justify-between items-center flex hover:text-green-500 duration-300'> +
+
{locale.COMMON.NEXT_POST}
+
{next.title}
+
+
) diff --git a/themes/gitbook/components/BlogPostCard.js b/themes/gitbook/components/BlogPostCard.js index 72755672..a311f47c 100644 --- a/themes/gitbook/components/BlogPostCard.js +++ b/themes/gitbook/components/BlogPostCard.js @@ -3,7 +3,6 @@ import NotionIcon from '@/components/NotionIcon' import { siteConfig } from '@/lib/config' import Link from 'next/link' import { useRouter } from 'next/router' -import CONFIG from '../config' const BlogPostCard = ({ post, className }) => { const router = useRouter() @@ -14,8 +13,8 @@ const BlogPostCard = ({ post, className }) => {
+ className={`${className} relative py-1.5 cursor-pointer px-1.5 rounded-md hover:bg-gray-50 + ${currentSelected ? 'text-green-500 dark:bg-yellow-100 dark:text-yellow-600 font-semibold' : ' dark:hover:bg-yellow-100 dark:hover:text-yellow-600'}`}>
{siteConfig('POST_TITLE_ICON') && ( @@ -23,10 +22,9 @@ const BlogPostCard = ({ post, className }) => { {post.title}
{/* 最新文章加个红点 */} - {post?.isLatest && - siteConfig('GITBOOK_LATEST_POST_RED_BADGE', false, CONFIG) && ( - - )} + {post?.isLatest && siteConfig('GITBOOK_LATEST_POST_RED_BADGE') && ( + + )}
) diff --git a/themes/gitbook/components/Catalog.js b/themes/gitbook/components/Catalog.js index e4a20bdf..9173fa7d 100644 --- a/themes/gitbook/components/Catalog.js +++ b/themes/gitbook/components/Catalog.js @@ -1,4 +1,3 @@ -import { useGlobal } from '@/lib/global' import { isBrowser } from '@/lib/utils' import throttle from 'lodash.throttle' import { uuidToId } from 'notion-utils' @@ -14,7 +13,6 @@ const Catalog = ({ post }) => { const toc = post?.toc // 同步选中目录事件 const [activeSection, setActiveSection] = useState(null) - const {locale}= useGlobal() // 监听滚动事件 useEffect(() => { @@ -69,25 +67,28 @@ const Catalog = ({ post }) => { return ( <> -
{locale.COMMON.TABLE_OF_CONTENTS}
+ {/*
+ {locale.COMMON.TABLE_OF_CONTENTS} +
*/} +
-
) } diff --git a/themes/gitbook/components/NavPostItem.js b/themes/gitbook/components/NavPostItem.js index 46664a56..5e345014 100644 --- a/themes/gitbook/components/NavPostItem.js +++ b/themes/gitbook/components/NavPostItem.js @@ -2,7 +2,6 @@ import Badge from '@/components/Badge' import Collapse from '@/components/Collapse' import { siteConfig } from '@/lib/config' import { useEffect, useState } from 'react' -import CONFIG from '../config' import BlogPostCard from './BlogPostCard' /** @@ -14,7 +13,7 @@ import BlogPostCard from './BlogPostCard' */ const NavPostItem = props => { const { group, expanded, toggleItem } = props // 接收传递的展开状态和切换函数 - const hoverExpand = siteConfig('GITBOOK_FOLDER_HOVER_EXPAND', false, CONFIG) + const hoverExpand = siteConfig('GITBOOK_FOLDER_HOVER_EXPAND') const [isTouchDevice, setIsTouchDevice] = useState(false) // 检测是否为触摸设备 @@ -55,13 +54,15 @@ const NavPostItem = props => { onClick={toggleOpenSubMenu} className='cursor-pointer relative flex justify-between text-sm p-2 hover:bg-gray-50 rounded-md dark:hover:bg-yellow-100 dark:hover:text-yellow-600' key={group?.category}> - {group?.category} + + {group?.category} +
{groupHasLatest && - siteConfig('GITBOOK_LATEST_POST_RED_BADGE', false, CONFIG) && + siteConfig('GITBOOK_LATEST_POST_RED_BADGE') && !expanded && } diff --git a/themes/gitbook/components/NavPostList.js b/themes/gitbook/components/NavPostList.js index 7bc67c44..aa86fed9 100644 --- a/themes/gitbook/components/NavPostList.js +++ b/themes/gitbook/components/NavPostList.js @@ -3,6 +3,7 @@ import { useGlobal } from '@/lib/global' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import CONFIG from '../config' +import BlogPostCard from './BlogPostCard' import NavPostItem from './NavPostItem' /** @@ -13,7 +14,7 @@ import NavPostItem from './NavPostItem' * @constructor */ const NavPostList = props => { - const { filteredNavPages } = props + const { filteredNavPages, post } = props const { locale, currentSearch } = useGlobal() const router = useRouter() @@ -80,11 +81,22 @@ const NavPostList = props => { ) } + // 如果href + const href = siteConfig('GITBOOK_INDEX_PAGE') + '' + + const homePost = { + id: '-1', + title: siteConfig('DESCRIPTION'), + href: href.indexOf('/') !== 0 ? '/' + href : href + } return (
+ className='w-full flex-grow space-y-0.5 pr-4 tracking-wider'> + {/* 当前文章 */} + + {/* 文章列表 */} {categoryFolders?.map((group, index) => ( { } return ( -
+
{ id='wrapper' className={ (siteConfig('LAYOUT_SIDEBAR_REVERSE') ? 'flex-row-reverse' : '') + - 'relative flex justify-between w-full h-full mx-auto' + 'relative flex justify-between w-full gap-x-6 h-full mx-auto max-w-screen-4xl' }> {/* 左侧推拉抽屉 */} {fullWidth ? null : (
-
+
{/* 导航 */} -
+
{/* 嵌入 */} {slotLeft} - {/* 搜索框 */} - - {/* 文章列表 */} {/* 所有文章列表 */} - +
{/* 页脚 */}
@@ -171,27 +167,17 @@ const LayoutBase = props => {
)} + {/* 中间内容区域 */}
+ className={`w-full ${fullWidth ? 'px-10' : 'max-w-3xl px-3 lg:px-0'} justify-center mx-auto`}> {slotTop} - {/* */} {children} - {/* */} {/* Google广告 */} @@ -207,14 +193,13 @@ const LayoutBase = props => {
- {/* 右侧侧推拉抽屉 */} + {/* 右侧 */} {fullWidth ? null : (