diff --git a/themes/gitbook/components/NavPostList.js b/themes/gitbook/components/NavPostList.js index 2c7fceff..be84e9ba 100644 --- a/themes/gitbook/components/NavPostList.js +++ b/themes/gitbook/components/NavPostList.js @@ -61,10 +61,12 @@ const NavPostList = props => { // 如果都没有选中默认打开第一个 useEffect(() => { - if (expandedGroups.length === 0) { - setExpandedGroups([0]) - } - }, []) + setTimeout(() => { + if (expandedGroups.length === 0) { + setExpandedGroups([0]) + } + }, 500) + }, [router]) // 折叠项切换,当折叠或展开数组时会调用 const toggleItem = index => { diff --git a/themes/starter/components/Blog.js b/themes/starter/components/Blog.js index 168c2984..2dff9e82 100644 --- a/themes/starter/components/Blog.js +++ b/themes/starter/components/Blog.js @@ -1,8 +1,8 @@ /* eslint-disable @next/next/no-img-element */ import { siteConfig } from '@/lib/config' -import CONFIG from '../config' import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils' import Link from 'next/link' +import CONFIG from '../config' /** * 博文列表 @@ -10,71 +10,72 @@ import Link from 'next/link' * @returns */ export const Blog = ({ posts }) => { - return <> - {/* */} -
-
- {/* 区块标题文字 */} -
-
-
- - {siteConfig('STARTER_BLOG_TITLE', null, CONFIG)} - -

- {siteConfig('STARTER_BLOG_TEXT_1', null, CONFIG)} -

-

- -

-
-
+ return ( + <> + {/* */} +
+
+ {/* 区块标题文字 */} +
+
+
+ + {siteConfig('STARTER_BLOG_TITLE', null, CONFIG)} + +

+ {siteConfig('STARTER_BLOG_TEXT_1', null, CONFIG)} +

+

+
- {/* 博客列表 此处优先展示3片文章 */} -
- {posts?.map((item, index) => { - const url = checkContainHttp(item.slug) ? sliceUrlFromHttp(item.slug) : `${siteConfig('SUB_PATH', '')}/${item.slug}` - return
-
-
- +
+ {/* 博客列表 此处优先展示3片文章 */} +
+ {posts?.map((item, index) => { + const url = checkContainHttp(item.slug) + ? sliceUrlFromHttp(item.slug) + : `${siteConfig('SUB_PATH', '')}/${item.slug}` + return ( +
+
+
+ {item.title} - +
- + {item.publishDay} - -

- - {item.title} - -

-

- {item.summary} -

-
+ +

+ + {item.title} + +

+

+ {item.summary} +

+
- }) } -
+ ) + })} +
-
- {/* */} +
+ {/* */} + ) }