最新文章组件,按修改时间倒序

This commit is contained in:
tangly1024
2022-04-07 17:00:10 +08:00
parent 7c63f7a5d6
commit cab1c2da68
7 changed files with 44 additions and 49 deletions

View File

@@ -8,7 +8,7 @@ import CONFIG_NEXT from './config_next'
export const LayoutIndex = (props) => {
const { latestPosts } = props
const rightAreaSlot = CONFIG_NEXT.RIGHT_LATEST_POSTS && <Card><LatestPostsGroup posts={latestPosts} /></Card>
const rightAreaSlot = CONFIG_NEXT.RIGHT_LATEST_POSTS && <Card><LatestPostsGroup latestPosts={latestPosts} /></Card>
return <LayoutBase
headerSlot={CONFIG_NEXT.HOME_BANNER && <Header />}
sideBarSlot={<LatestPostsGroup posts={latestPosts} />}
@@ -18,6 +18,6 @@ export const LayoutIndex = (props) => {
{CONFIG_NEXT.POST_LIST_TYPE !== 'page'
? <BlogPostListScroll {...props} showSummary={true} />
: <BlogPostListPage {...props} />
}
}
</LayoutBase>
}

View File

@@ -9,8 +9,8 @@ import { useRouter } from 'next/router'
* @param sliceCount 截取展示的数量 默认6
* @constructor
*/
const LatestPostsGroup = ({ posts }) => {
if (!posts) {
const LatestPostsGroup = ({ latestPosts }) => {
if (!latestPosts) {
return <></>
}
// 获取当前路径
@@ -21,11 +21,11 @@ const LatestPostsGroup = ({ posts }) => {
<>
<div className="text-sm pb-1 px-2 flex flex-nowrap justify-between">
<div className="font-light text-gray-600 dark:text-gray-200">
<i className="mr-2 fas fa-archive" />
<i className="mr-2 fas fa-history" />
{locale.COMMON.LATEST_POSTS}
</div>
</div>
{posts.map(post => {
{latestPosts.map(post => {
const selected = currentPath === `${BLOG.SUB_PATH}/article/${post.slug}`
return (
<Link

View File

@@ -12,7 +12,7 @@ const CONFIG_NEXT = {
// 右侧组件
RIGHT_BAR: true, // 是否显示右侧栏
RIGHT_LATEST_POSTS: false, // 右侧栏最新文章
RIGHT_LATEST_POSTS: true, // 右侧栏最新文章
RIGHT_CATEGORY_LIST: true, // 右侧边栏文章分类列表
RIGHT_TAG_LIST: true, // 右侧边栏标签分类列表
RIGHT_AD: false, // 右侧广告