Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 28, 2024
2 parents 051f933 + ffe78a5 commit b817e0e
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
42 changes: 28 additions & 14 deletions themes/gitbook/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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) {
Expand All @@ -329,6 +338,10 @@ const LayoutSlug = props => {
}, [post])
return (
<>
<Head>
<title>{title}</title>
</Head>

{/* 文章锁 */}
{lock && <ArticleLock validPassword={validPassword} />}

Expand Down Expand Up @@ -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
}

4 changes: 2 additions & 2 deletions themes/magzine/components/PostGroupArchive.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ const PostGroupArchive = ({ posts = [], archiveTitle }) => {
</div>

{/* 列表 */}
<ul className='grid grid-cols-1 lg:grid-cols-4 gap-4'>
<div className='grid grid-cols-1 lg:grid-cols-4 gap-4'>
{posts?.map((p, index) => {
return <PostItemCard key={index} post={p} />
})}
</ul>
</div>
</div>
)
}
Expand Down
4 changes: 2 additions & 2 deletions themes/magzine/components/PostListHorizontal.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ const PostListHorizontal = ({ title, href, posts, hasBg }) => {
)}
</div>
{/* 列表 */}
<ul className='hidden lg:grid grid-cols-1 lg:grid-cols-4 gap-4'>
<div className='hidden lg:grid grid-cols-1 lg:grid-cols-4 gap-4'>
{posts?.map((p, index) => {
return <PostItemCard key={index} post={p} />
})}
</ul>
</div>
<div className='block lg:hidden px-2'>
<Swiper posts={posts} />
{href && (
Expand Down

0 comments on commit b817e0e

Please sign in to comment.