修复错误单词,修复slug页错误的allPosts
This commit is contained in:
tangly1024
2021-11-04 14:06:32 +08:00
parent 3cb42c5ea9
commit 40db3aae2b
5 changed files with 14 additions and 12 deletions

View File

@@ -6,7 +6,7 @@ import React, { useImperativeHandle, useState } from 'react'
import InfoCard from '@/components/InfoCard'
import TagList from '@/components/TagList'
import Logo from '@/components/Logo'
import LastedPosts from '@/components/LastedPosts'
import LatestPosts from '@/components/LatestPosts'
/**
* 抽屉面板,可以从侧面拉出
@@ -58,7 +58,7 @@ const Drawer = ({ post, currentTag, cRef, tags, posts }) => {
{/* 最新文章 */}
{posts && (
<div className='mt-2 sticky top-0'>
<LastedPosts posts={posts}/>
<LatestPosts posts={posts}/>
</div>
)}

View File

@@ -8,7 +8,7 @@ import { useRouter } from 'next/router'
* @param posts
* @constructor
*/
const LastedPosts = ({ posts }) => {
const LatestPosts = ({ posts }) => {
// 按时间排序
if (posts) {
posts = posts.sort((a, b) => {
@@ -28,11 +28,11 @@ const LastedPosts = ({ posts }) => {
{posts.map(post => {
return (
<Link key={post.id} title={post.title} href={`${BLOG.path}/article/${post.slug}`} >
<div className={(router.asPath === `${BLOG.path}/article/${post.slug}` ? 'bg-gray-200 dark:bg-black' : '') + ' text-xs leading-5 py-1.5 px-5 cursor-pointer hover:underline flex'}>
<div className={(router.asPath === `${BLOG.path}/article/${post.slug}` ? 'bg-gray-200 dark:bg-black' : '') + ' text-xs leading-5 py-1.5 px-5 flex'}>
<div className='mr-2 text-gray-500'>
{formatDateFmt(post.lastEditedTime, 'yyyy/MM/dd')}
</div>
<div className='text-sm flex w-50 overflow-x-hidden whitespace-nowrap dark:text-gray-300'>
<div className='text-sm flex w-50 overflow-x-hidden whitespace-nowrap dark:text-gray-300 cursor-pointer hover:underline'>
{post.title}
</div>
</div>
@@ -42,4 +42,4 @@ const LastedPosts = ({ posts }) => {
</div>
</>
}
export default LastedPosts
export default LatestPosts

View File

@@ -17,8 +17,10 @@ const SearchInput = ({ currentTag, currentSearch }) => {
}
}
const handleKeyUp = (e) => {
if (e.keyCode === 13) {
if (e.keyCode === 13) { // 回车
handleSearch(searchInputRef.current.value)
} else if (e.keyCode === 27) { // ESC
cleanSearch()
}
}
const cleanSearch = () => {

View File

@@ -2,7 +2,7 @@ import React from 'react'
import MenuButtonGroup from '@/components/MenuButtonGroup'
import InfoCard from '@/components/InfoCard'
import TagList from '@/components/TagList'
import LastedPosts from '@/components/LastedPosts'
import LatestPosts from '@/components/LatestPosts'
const SideBar = ({ tags, currentTag, post, posts }) => {
// 按时间排序
@@ -29,7 +29,7 @@ const SideBar = ({ tags, currentTag, post, posts }) => {
{/* 最新文章 */}
{posts && (
<div className='mt-2'>
<LastedPosts posts={posts}/>
<LatestPosts posts={posts}/>
</div>
)}

View File

@@ -27,7 +27,7 @@ import 'prismjs/components/prism-typescript'
const mapPageUrl = id => {
return 'https://www.notion.so/' + id.replace(/-/g, '')
}
const BlogPost = ({ post, blockMap, tags, prev, next, posts }) => {
const ArticleDetail = ({ post, blockMap, tags, prev, next, posts }) => {
if (!post) {
return <Custom404/>
}
@@ -39,7 +39,7 @@ const BlogPost = ({ post, blockMap, tags, prev, next, posts }) => {
const targetRef = useRef(null)
const url = BLOG.link + useRouter().asPath
return <BaseLayout meta={meta} tags={tags} totalPosts={post} posts={posts}>
return <BaseLayout meta={meta} tags={tags} post={post} totalPosts={posts} >
{/* 阅读进度条 */}
<Progress targetRef={targetRef} />
@@ -209,4 +209,4 @@ export async function getStaticProps ({ params: { slug } }) {
}
}
export default BlogPost
export default ArticleDetail