mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-04 23:16:53 +00:00
Merge branch 'main' of https://github.com/tangly1024/NotionNext
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import Link from 'next/link'
|
||||
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
|
||||
|
||||
/**
|
||||
* 归档分组
|
||||
@@ -13,8 +14,10 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
|
||||
{archiveTitle}
|
||||
</div>
|
||||
<ul>
|
||||
{archivePosts[archiveTitle]?.map(post => (
|
||||
<li key={post.id}
|
||||
{archivePosts[archiveTitle]?.map(post => {
|
||||
const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
|
||||
|
||||
return <li key={post.id}
|
||||
className="border-l-2 p-1 text-xs md:text-base items-center hover:scale-x-105 hover:border-gray-500 dark:hover:border-gray-300 dark:border-gray-400 transform duration-500"
|
||||
>
|
||||
<div id={post?.publishDay}>
|
||||
@@ -23,13 +26,13 @@ export default function BlogArchiveItem({ archiveTitle, archivePosts }) {
|
||||
</span>{' '}
|
||||
|
||||
|
||||
<Link passHref href={`${siteConfig('SUB_PATH', '')}/${post.slug}`}
|
||||
<Link passHref href={url}
|
||||
className="dark:text-gray-400 dark:hover:text-gray-300 overflow-x-hidden hover:underline cursor-pointer text-gray-600">
|
||||
{post.title}
|
||||
</Link>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -2,14 +2,16 @@ import Link from 'next/link'
|
||||
import NotionIcon from './NotionIcon'
|
||||
import { useRouter } from 'next/router'
|
||||
import { siteConfig } from '@/lib/config'
|
||||
import { checkContainHttp, sliceUrlFromHttp } from '@/lib/utils'
|
||||
|
||||
const BlogPostCard = ({ post, className }) => {
|
||||
const router = useRouter()
|
||||
const currentSelected = router.asPath.split('?')[0] === '/' + post.slug
|
||||
let pageIcon = post.pageIcon !== '' ? post.pageIcon : siteConfig('IMG_LAZY_LOAD_PLACEHOLDER')
|
||||
pageIcon = post.pageIcon.indexOf('amazonaws.com') !== -1 ? post.pageIcon + '&width=88' : post.pageIcon
|
||||
const url = checkContainHttp(post.slug) ? sliceUrlFromHttp(post.slug) : `${siteConfig('SUB_PATH', '')}/${post.slug}`
|
||||
return (
|
||||
<Link href={`${siteConfig('SUB_PATH', '')}/${removeHttp(post.slug)}`} target={(checkRemoveHttp(post.slug) ? '_blank' : '_self')} passHref>
|
||||
<Link href={`${url}`} target={(checkContainHttp(post.slug) ? '_blank' : '_self')} passHref>
|
||||
<div key={post.id} className={`${className} h-full rounded-2xl p-4 dark:bg-neutral-800 cursor-pointer bg-white hover:bg-white dark:hover:bg-gray-800 ${currentSelected ? 'bg-green-50 text-green-500' : ''}`}>
|
||||
<div className="stack-entry w-full flex space-x-3 select-none dark:text-neutral-200">
|
||||
<NotionIcon icon={pageIcon} size='10' className='text-6xl w-11 h-11 mx-1 my-0 flex-none' />
|
||||
@@ -21,28 +23,6 @@ const BlogPostCard = ({ post, className }) => {
|
||||
</div>
|
||||
</Link>
|
||||
)
|
||||
function removeHttp(str) {
|
||||
// 检查字符串是否包含http
|
||||
if (str.includes('http')) {
|
||||
// 如果包含,找到http的位置
|
||||
const index = str.indexOf('http');
|
||||
// 返回http之后的部分
|
||||
return str.slice(index, str.length);
|
||||
} else {
|
||||
// 如果不包含,返回原字符串
|
||||
return str;
|
||||
}
|
||||
}
|
||||
function checkRemoveHttp(str) {
|
||||
// 检查字符串是否包含http
|
||||
if (str.includes('http')) {
|
||||
// 如果包含,找到http的位置
|
||||
return str.indexOf('http') > -1
|
||||
} else {
|
||||
// 不包含
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default BlogPostCard
|
||||
|
||||
@@ -13,15 +13,9 @@ import { siteConfig } from '@/lib/config'
|
||||
* @constructor
|
||||
*/
|
||||
const BlogPostListAll = (props) => {
|
||||
// const { customMenu, posts, category, tag, allNavPages, categoryOptions } = props
|
||||
// const [filteredNavPages, setFilteredNavPages] = useState(allNavPages)
|
||||
const { customMenu } = props
|
||||
|
||||
// const [filteredNavPages, setFilteredNavPages] = useState(allNavPages)
|
||||
const { filteredNavPages, setFilteredNavPages, allNavPages } = useNavGlobal()
|
||||
// const [filteredNavPages] = useState(allNavPages)
|
||||
|
||||
// const router = useRouter()
|
||||
// 对自定义分类格式化,方便后续使用分类名称做索引,检索同步图标信息
|
||||
// 目前只支持二级分类
|
||||
const links = customMenu
|
||||
@@ -29,9 +23,6 @@ const BlogPostListAll = (props) => {
|
||||
// for循环遍历数组
|
||||
links?.map((link, i) => {
|
||||
const linkTitle = link.title + ''
|
||||
// console.log('####### link')
|
||||
// console.log(link)
|
||||
// filterLinks[linkTitle] = link
|
||||
filterLinks[linkTitle] = { title: link.title, icon: link.icon, pageIcon: link.pageIcon }
|
||||
if (link?.subMenus) {
|
||||
link.subMenus?.map((group, index) => {
|
||||
@@ -44,22 +35,10 @@ const BlogPostListAll = (props) => {
|
||||
}
|
||||
})
|
||||
|
||||
console.log('####### filterLinks')
|
||||
console.log(filterLinks)
|
||||
|
||||
// console.log('####### filterLinks')
|
||||
// console.log(filterLinks)
|
||||
|
||||
const selectedSth = false
|
||||
const groupedArray = filteredNavPages?.reduce((groups, item) => {
|
||||
const categoryName = item?.category ? item?.category : '' // 将category转换为字符串
|
||||
const categoryIcon = filterLinks[categoryName]?.icon ? filterLinks[categoryName]?.icon : '' // 将pageIcon转换为字符串
|
||||
|
||||
// console.log('####### categoryName')
|
||||
// console.log(categoryName)
|
||||
// console.log('####### categoryIcon')
|
||||
// console.log(categoryIcon)
|
||||
|
||||
let existingGroup = null
|
||||
// 开启自动分组排序
|
||||
if (JSON.parse(siteConfig('NAV_AUTO_SORT', null, CONFIG))) {
|
||||
@@ -81,17 +60,9 @@ const BlogPostListAll = (props) => {
|
||||
groupedArray?.map((group) => {
|
||||
// 自定义分类图标与post的category共用
|
||||
// 判断自定义分类与Post中category同名的项,将icon的值传递给post
|
||||
// let groupTitle = group?.category
|
||||
// item.icon = filterLinks[categoryName]?.icon ? filterLinks[categoryName]?.icon : ''
|
||||
// console.log('####### item')
|
||||
// console.log(item)
|
||||
|
||||
const groupSelected = false
|
||||
// for (const post of group?.items) {
|
||||
// if (router.asPath.split('?')[0] === '/' + post.slug) {
|
||||
// groupSelected = true
|
||||
// selectedSth = true
|
||||
// }
|
||||
// }
|
||||
|
||||
group.selected = groupSelected
|
||||
return null
|
||||
})
|
||||
@@ -110,27 +81,6 @@ const BlogPostListAll = (props) => {
|
||||
</div>
|
||||
}
|
||||
|
||||
// 处理自定义导航菜单项
|
||||
// let keyword = searchInputRef.current.value
|
||||
// if (keyword) {
|
||||
// keyword = keyword.trim()
|
||||
// } else {
|
||||
// setFilteredNavPages(allNavPages)
|
||||
// }
|
||||
// for (const filterGroup of filterAllNavPages) {
|
||||
// for (let i = filterGroup.items.length - 1; i >= 0; i--) {
|
||||
// const post = filterGroup.items[i]
|
||||
// const articleInfo = post.title + ''
|
||||
// const hit = articleInfo.toLowerCase().indexOf(keyword.toLowerCase()) > -1
|
||||
// if (!hit) {
|
||||
// // 删除
|
||||
// filterGroup.items.splice(i, 1)
|
||||
// }
|
||||
// }
|
||||
// if (filterGroup.items && filterGroup.items.length > 0) {
|
||||
// filterPosts.push(filterGroup)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
export default BlogPostListAll
|
||||
|
||||
Reference in New Issue
Block a user