gitbook 标签修改标题

This commit is contained in:
tangly1024.com
2024-11-27 14:13:55 +08:00
parent 5a985b3095
commit eb6ccb3290
3 changed files with 32 additions and 18 deletions

View File

@@ -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 (
<>
<Head>
<title>{title}</title>
</Head>
{/* 文章锁 */}
{lock && <ArticleLock validPassword={validPassword} />}
@@ -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
}