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 ( <> +
+