Skip to content

Commit

Permalink
Merge branch 'tangly1024:main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeafter619 authored Dec 13, 2024
2 parents d76d42b + 8493414 commit d8be487
Show file tree
Hide file tree
Showing 9 changed files with 1,616 additions and 1,987 deletions.
6 changes: 6 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export const siteConfig = (key, defaultVal = null, extendConfig = {}) => {
case 'TAG_SORT_BY_COUNT':
case 'THEME':
case 'LINK':
// LINK比较特殊,
if (key === 'LINK') {
if (!extendConfig || Object.keys(extendConfig).length === 0) {
break
}
}
return convertVal(
getValue(extendConfig[key], getValue(defaultVal, BLOG[key]))
)
Expand Down
4 changes: 3 additions & 1 deletion pages/category/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import { DynamicLayout } from '@/themes/theme'
*/
export default function Category(props) {
const theme = siteConfig('THEME', BLOG.THEME, props.NOTION_CONFIG)
return <DynamicLayout theme={theme} layoutName='LayoutPostList' {...props} />
return (
<DynamicLayout theme={theme} layoutName='LayoutCategoryIndex' {...props} />
)
}

export async function getStaticProps({ locale }) {
Expand Down
6 changes: 5 additions & 1 deletion pages/sitemap.xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export const getServerSideProps = async ctx => {
pageId: id,
from: 'sitemap.xml'
})
const link = siteConfig('LINK', '', siteData.NOTION_CONFIG)
const link = siteConfig(
'LINK',
siteData?.siteInfo?.link,
siteData.NOTION_CONFIG
)
const localeFields = generateLocalesSitemap(link, siteData.allPages, locale)
fields = fields.concat(localeFields)
}
Expand Down
2 changes: 1 addition & 1 deletion pages/tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useRouter } from 'next/router'
const TagIndex = props => {
const router = useRouter()
const theme = siteConfig('THEME', BLOG.THEME, props.NOTION_CONFIG)
return <DynamicLayout theme={theme} layoutName='LayoutPostList' {...props} />
return <DynamicLayout theme={theme} layoutName='LayoutTagIndex' {...props} />
}

export async function getStaticProps(req) {
Expand Down
2 changes: 1 addition & 1 deletion themes/gitbook/components/BottomMenuBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function BottomMenuBar({ post, className }) {
onClick={togglePageNavVisible}
className='inline-flex flex-col items-center justify-center px-5 border-gray-200 border-x hover:bg-gray-50 dark:hover:bg-gray-800 group dark:border-gray-600'>
<i className='fa-book fas w-5 h-5 mb-2 text-gray-500 dark:text-gray-400 group-hover:text-gray-600 dark:group-hover:text-gray-500' />
<span class='text-sm text-gray-500 dark:text-gray-400 group-hover:text-gray-600 dark:group-hover:text-gray-500'>
<span className='text-sm text-gray-500 dark:text-gray-400 group-hover:text-gray-600 dark:group-hover:text-gray-500'>
{locale.COMMON.ARTICLE_LIST}
</span>
</button>
Expand Down
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
Loading

0 comments on commit d8be487

Please sign in to comment.