mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-05 15:10:26 +00:00
feature:
修复错误单词,修复slug页错误的allPosts
This commit is contained in:
@@ -6,7 +6,7 @@ import React, { useImperativeHandle, useState } from 'react'
|
|||||||
import InfoCard from '@/components/InfoCard'
|
import InfoCard from '@/components/InfoCard'
|
||||||
import TagList from '@/components/TagList'
|
import TagList from '@/components/TagList'
|
||||||
import Logo from '@/components/Logo'
|
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 && (
|
{posts && (
|
||||||
<div className='mt-2 sticky top-0'>
|
<div className='mt-2 sticky top-0'>
|
||||||
<LastedPosts posts={posts}/>
|
<LatestPosts posts={posts}/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { useRouter } from 'next/router'
|
|||||||
* @param posts
|
* @param posts
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
const LastedPosts = ({ posts }) => {
|
const LatestPosts = ({ posts }) => {
|
||||||
// 按时间排序
|
// 按时间排序
|
||||||
if (posts) {
|
if (posts) {
|
||||||
posts = posts.sort((a, b) => {
|
posts = posts.sort((a, b) => {
|
||||||
@@ -28,11 +28,11 @@ const LastedPosts = ({ posts }) => {
|
|||||||
{posts.map(post => {
|
{posts.map(post => {
|
||||||
return (
|
return (
|
||||||
<Link key={post.id} title={post.title} href={`${BLOG.path}/article/${post.slug}`} >
|
<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'>
|
<div className='mr-2 text-gray-500'>
|
||||||
{formatDateFmt(post.lastEditedTime, 'yyyy/MM/dd')}
|
{formatDateFmt(post.lastEditedTime, 'yyyy/MM/dd')}
|
||||||
</div>
|
</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}
|
{post.title}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -42,4 +42,4 @@ const LastedPosts = ({ posts }) => {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
export default LastedPosts
|
export default LatestPosts
|
||||||
@@ -17,8 +17,10 @@ const SearchInput = ({ currentTag, currentSearch }) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const handleKeyUp = (e) => {
|
const handleKeyUp = (e) => {
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) { // 回车
|
||||||
handleSearch(searchInputRef.current.value)
|
handleSearch(searchInputRef.current.value)
|
||||||
|
} else if (e.keyCode === 27) { // ESC
|
||||||
|
cleanSearch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const cleanSearch = () => {
|
const cleanSearch = () => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from 'react'
|
|||||||
import MenuButtonGroup from '@/components/MenuButtonGroup'
|
import MenuButtonGroup from '@/components/MenuButtonGroup'
|
||||||
import InfoCard from '@/components/InfoCard'
|
import InfoCard from '@/components/InfoCard'
|
||||||
import TagList from '@/components/TagList'
|
import TagList from '@/components/TagList'
|
||||||
import LastedPosts from '@/components/LastedPosts'
|
import LatestPosts from '@/components/LatestPosts'
|
||||||
|
|
||||||
const SideBar = ({ tags, currentTag, post, posts }) => {
|
const SideBar = ({ tags, currentTag, post, posts }) => {
|
||||||
// 按时间排序
|
// 按时间排序
|
||||||
@@ -29,7 +29,7 @@ const SideBar = ({ tags, currentTag, post, posts }) => {
|
|||||||
{/* 最新文章 */}
|
{/* 最新文章 */}
|
||||||
{posts && (
|
{posts && (
|
||||||
<div className='mt-2'>
|
<div className='mt-2'>
|
||||||
<LastedPosts posts={posts}/>
|
<LatestPosts posts={posts}/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import 'prismjs/components/prism-typescript'
|
|||||||
const mapPageUrl = id => {
|
const mapPageUrl = id => {
|
||||||
return 'https://www.notion.so/' + id.replace(/-/g, '')
|
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) {
|
if (!post) {
|
||||||
return <Custom404/>
|
return <Custom404/>
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ const BlogPost = ({ post, blockMap, tags, prev, next, posts }) => {
|
|||||||
const targetRef = useRef(null)
|
const targetRef = useRef(null)
|
||||||
const url = BLOG.link + useRouter().asPath
|
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} />
|
<Progress targetRef={targetRef} />
|
||||||
|
|
||||||
@@ -209,4 +209,4 @@ export async function getStaticProps ({ params: { slug } }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default BlogPost
|
export default ArticleDetail
|
||||||
|
|||||||
Reference in New Issue
Block a user