From eb6ccb3290dd95731eb7ac73ae14c086bdf66b8a Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 27 Nov 2024 14:13:55 +0800 Subject: [PATCH] =?UTF-8?q?gitbook=20=E6=A0=87=E7=AD=BE=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/gitbook/index.js | 42 ++++++++++++------- themes/magzine/components/PostGroupArchive.js | 4 +- .../magzine/components/PostListHorizontal.js | 4 +- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/themes/gitbook/index.js b/themes/gitbook/index.js index 07197fdf..b737e9f8 100644 --- a/themes/gitbook/index.js +++ b/themes/gitbook/index.js @@ -15,6 +15,7 @@ import { isBrowser } from '@/lib/utils' import { getShortId } from '@/lib/utils/pageId' import { SignIn, SignUp } from '@clerk/nextjs' import dynamic from 'next/dynamic' +import Head from 'next/head' import Link from 'next/link' import { useRouter } from 'next/router' import { createContext, useContext, useEffect, useRef, useState } from 'react' @@ -305,8 +306,16 @@ const LayoutPostList = props => { * @returns */ const LayoutSlug = props => { - const { post, prev, next, lock, validPassword } = props + const { post, prev, next, siteInfo, lock, validPassword } = props const router = useRouter() + // 如果是文档首页文章,则修改浏览器标签 + const index = siteConfig('GITBOOK_INDEX_PAGE', 'about', CONFIG) + const basePath = router.asPath.split('?')[0] + const title = + basePath?.indexOf(index) > 0 + ? `${post?.title} | ${siteInfo?.description}` + : `${post?.title} | ${siteInfo?.title}` + useEffect(() => { // 404 if (!post) { @@ -329,6 +338,10 @@ const LayoutSlug = props => { }, [post]) return ( <> + + {title} + + {/* 文章锁 */} {lock && } @@ -574,17 +587,18 @@ const LayoutDashboard = props => { } export { - Layout404, - LayoutArchive, - LayoutBase, - LayoutCategoryIndex, - LayoutDashboard, - LayoutIndex, - LayoutPostList, - LayoutSearch, - LayoutSignIn, - LayoutSignUp, - LayoutSlug, - LayoutTagIndex, - CONFIG as THEME_CONFIG + Layout404, + LayoutArchive, + LayoutBase, + LayoutCategoryIndex, + LayoutDashboard, + LayoutIndex, + LayoutPostList, + LayoutSearch, + LayoutSignIn, + LayoutSignUp, + LayoutSlug, + LayoutTagIndex, + CONFIG as THEME_CONFIG } + diff --git a/themes/magzine/components/PostGroupArchive.js b/themes/magzine/components/PostGroupArchive.js index a7314c3d..663ee75b 100644 --- a/themes/magzine/components/PostGroupArchive.js +++ b/themes/magzine/components/PostGroupArchive.js @@ -22,11 +22,11 @@ const PostGroupArchive = ({ posts = [], archiveTitle }) => { {/* 列表 */} - + ) } diff --git a/themes/magzine/components/PostListHorizontal.js b/themes/magzine/components/PostListHorizontal.js index 31532a8b..5e5544df 100644 --- a/themes/magzine/components/PostListHorizontal.js +++ b/themes/magzine/components/PostListHorizontal.js @@ -32,11 +32,11 @@ const PostListHorizontal = ({ title, href, posts, hasBg }) => { )} {/* 列表 */} - +
{href && (