Merge pull request #2549 from tangly1024/fix/fukasawa-scroll-page

主题分页相关调整,fix fukasawa scroll功能
This commit is contained in:
tangly1024
2024-06-28 16:58:46 +08:00
committed by GitHub
32 changed files with 131 additions and 105 deletions

View File

@@ -71,7 +71,7 @@ export async function getStaticPaths() {
// 处理文章页数 // 处理文章页数
const postCount = categoryPosts.length const postCount = categoryPosts.length
const totalPages = Math.ceil( const totalPages = Math.ceil(
postCount / siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) postCount / siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
) )
if (totalPages > 1) { if (totalPages > 1) {
for (let i = 1; i <= totalPages; i++) { for (let i = 1; i <= totalPages; i++) {

View File

@@ -23,7 +23,7 @@ export async function getStaticPaths({ locale }) {
const from = 'page-paths' const from = 'page-paths'
const { postCount, NOTION_CONFIG } = await getGlobalData({ from, locale }) const { postCount, NOTION_CONFIG } = await getGlobalData({ from, locale })
const totalPages = Math.ceil( const totalPages = Math.ceil(
postCount / siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) postCount / siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
) )
return { return {
// remove first page, we 're not gonna handle that. // remove first page, we 're not gonna handle that.

View File

@@ -27,7 +27,6 @@ export const getServerSideProps = async ctx => {
'Cache-Control', 'Cache-Control',
'public, max-age=3600, stale-while-revalidate=59' 'public, max-age=3600, stale-while-revalidate=59'
) )
console.log('fff', fields)
return getServerSideSitemap(ctx, fields) return getServerSideSitemap(ctx, fields)
} }

View File

@@ -56,7 +56,7 @@ export async function getStaticPaths() {
// 处理文章页数 // 处理文章页数
const postCount = tagPosts.length const postCount = tagPosts.length
const totalPages = Math.ceil( const totalPages = Math.ceil(
postCount / siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) postCount / siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
) )
if (totalPages > 1) { if (totalPages > 1) {
for (let i = 1; i <= totalPages; i++) { for (let i = 1; i <= totalPages; i++) {

View File

@@ -14,7 +14,7 @@ import ProductCard from './ProductCard'
*/ */
const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE) const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
const showPagination = postCount >= POSTS_PER_PAGE const showPagination = postCount >= POSTS_PER_PAGE
if (!posts || posts.length === 0 || page > totalPage) { if (!posts || posts.length === 0 || page > totalPage) {

View File

@@ -20,7 +20,7 @@ const BlogPostListScroll = ({
siteInfo siteInfo
}) => { }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const [page, updatePage] = useState(1) const [page, updatePage] = useState(1)
const postsToShow = getListByPage(posts, page, POSTS_PER_PAGE) const postsToShow = getListByPage(posts, page, POSTS_PER_PAGE)

View File

@@ -14,7 +14,7 @@ export const BlogListPage = props => {
const { locale, NOTION_CONFIG } = useGlobal() const { locale, NOTION_CONFIG } = useGlobal()
const router = useRouter() const router = useRouter()
const totalPage = Math.ceil( const totalPage = Math.ceil(
postCount / siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) postCount / siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
) )
const currentPage = +page const currentPage = +page

View File

@@ -13,7 +13,7 @@ export const BlogListScroll = props => {
const { posts } = props const { posts } = props
const { locale, NOTION_CONFIG } = useGlobal() const { locale, NOTION_CONFIG } = useGlobal()
const [page, updatePage] = useState(1) const [page, updatePage] = useState(1)
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
let hasMore = false let hasMore = false
const postsToShow = posts const postsToShow = posts

View File

@@ -24,7 +24,6 @@ const SearchInput = ({ currentTag, keyword, cRef }) => {
const key = searchInputRef.current.value const key = searchInputRef.current.value
if (key && key !== '') { if (key && key !== '') {
router.push({ pathname: '/search/' + key }).then(r => { router.push({ pathname: '/search/' + key }).then(r => {
console.log('搜索', key)
}) })
} else { } else {
router.push({ pathname: '/' }).then(r => { router.push({ pathname: '/' }).then(r => {

View File

@@ -1,6 +1,7 @@
import LazyImage from '@/components/LazyImage' import LazyImage from '@/components/LazyImage'
import NotionIcon from '@/components/NotionIcon' import NotionIcon from '@/components/NotionIcon'
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config'
import { useGlobal } from '@/lib/global'
import Link from 'next/link' import Link from 'next/link'
import CONFIG from '../config' import CONFIG from '../config'
import TagItemMini from './TagItemMini' import TagItemMini from './TagItemMini'
@@ -10,7 +11,8 @@ import TagItemMini from './TagItemMini'
* @param {*} param0 * @param {*} param0
* @returns * @returns
*/ */
const BlogCard = ({ index, post, showSummary, siteInfo }) => { const BlogCard = ({ showAnimate, post, showSummary }) => {
const {siteInfo} =useGlobal()
const showPreview = const showPreview =
siteConfig('FUKASAWA_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap siteConfig('FUKASAWA_POST_LIST_PREVIEW', null, CONFIG) && post.blockMap
// fukasawa 强制显示图片 // fukasawa 强制显示图片
@@ -24,11 +26,12 @@ const BlogCard = ({ index, post, showSummary, siteInfo }) => {
const showPageCover = const showPageCover =
siteConfig('FUKASAWA_POST_LIST_COVER', null, CONFIG) && siteConfig('FUKASAWA_POST_LIST_COVER', null, CONFIG) &&
post?.pageCoverThumbnail post?.pageCoverThumbnail
const FUKASAWA_POST_LIST_ANIMATION = siteConfig( const FUKASAWA_POST_LIST_ANIMATION = siteConfig(
'FUKASAWA_POST_LIST_ANIMATION', 'FUKASAWA_POST_LIST_ANIMATION',
null, null,
CONFIG CONFIG
) ) || showAnimate
// 动画样式 首屏卡片不用,后面翻出来的加动画 // 动画样式 首屏卡片不用,后面翻出来的加动画
const aosProps = FUKASAWA_POST_LIST_ANIMATION const aosProps = FUKASAWA_POST_LIST_ANIMATION

View File

@@ -17,8 +17,9 @@ import PaginationSimple from './PaginationSimple'
*/ */
const BlogListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { const BlogListPage = ({ page = 1, posts = [], postCount, siteInfo }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const postsPerPage = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil( const totalPage = Math.ceil(
postCount / parseInt(siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG)) postCount / postsPerPage
) )
const showNext = page < totalPage const showNext = page < totalPage
@@ -33,23 +34,27 @@ const BlogListPage = ({ page = 1, posts = [], postCount, siteInfo }) => {
return () => window.removeEventListener('resize', handleResize) return () => window.removeEventListener('resize', handleResize)
}, []) }, [])
/** /**
* 文章重新布局,使纵向排列看起来是横向排列 * 文章重新布局,使纵向排列看起来是横向排列
*/ */
useEffect(() => { useEffect(() => {
const count = posts?.length || 0 const count = posts?.length || 0;
const rows = Math.ceil(count / columns) const rows = Math.ceil(count / columns);
const newFilterPosts = [] const newFilterPosts = new Array(count);
for (let i = 0; i < columns; i++) {
for (let j = 0; j < rows; j++) { let index = 0;
const index = j * columns + i for (let col = 0; col < columns; col++) {
if (index < count) { for (let row = 0; row < rows; row++) {
newFilterPosts.push(deepClone(posts[index])) const sourceIndex = row * columns + col;
if (sourceIndex < count) {
newFilterPosts[index] = deepClone(posts[sourceIndex]);
index++;
}
} }
}
} }
setFilterPosts(newFilterPosts)
}, [columns, posts]) setFilterPosts(newFilterPosts);
}, [columns, posts]);
if (!filterPosts || filterPosts.length === 0) { if (!filterPosts || filterPosts.length === 0) {
return <BlogPostListEmpty /> return <BlogPostListEmpty />

View File

@@ -1,41 +1,36 @@
import { siteConfig } from '@/lib/config' import { siteConfig } from '@/lib/config';
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global';
import { useEffect, useRef, useState } from 'react' import throttle from 'lodash.throttle';
import BlogCard from './BlogCard' import { useCallback, useEffect, useRef, useState } from 'react';
import BlogPostListEmpty from './BlogListEmpty' import BlogCard from './BlogCard';
import BlogPostListEmpty from './BlogListEmpty';
const BlogListScroll = ({ posts }) => {
const { locale, NOTION_CONFIG } = useGlobal();
const [page, setPage] = useState(1);
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG);
const [filterPostsGroups, setFilterPostsGroups] = useState([]);
// 每页显示的文章数量
const postsPerPage = POSTS_PER_PAGE;
// 计算总页数
const totalPages = Math.ceil(posts.length / postsPerPage);
// 加载更多文章
const loadMorePosts = () => {
if (page < totalPages) {
setPage(page + 1);
}
};
/**
* 文章列表分页表格
* @param page 当前页
* @param posts 所有文章
* @param tags 所有标签
* @returns {JSX.Element}
* @constructor
*/
const BlogListScroll = props => {
const { posts = [], siteInfo } = props
const { locale, NOTION_CONFIG } = useGlobal()
const targetRef = useRef(null) const targetRef = useRef(null)
const [page, updatePage] = useState(1)
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG)
let hasMore = false
const postsToShow = posts
? Object.assign(posts).slice(0, POSTS_PER_PAGE * page)
: []
if (posts) {
const totalCount = posts.length
hasMore = page * POSTS_PER_PAGE < totalCount
}
const handleGetMore = () => {
if (!hasMore) return
updatePage(page + 1)
}
// 监听滚动自动分页加载 // 监听滚动自动分页加载
const scrollTrigger = () => { const scrollTrigger = useCallback(
requestAnimationFrame(() => { throttle(() => {
const scrollS = window.scrollY + window.outerHeight const scrollS = window.scrollY + window.outerHeight
const clientHeight = targetRef const clientHeight = targetRef
? targetRef.current ? targetRef.current
@@ -43,47 +38,64 @@ const BlogListScroll = props => {
: 0 : 0
: 0 : 0
if (scrollS > clientHeight + 100) { if (scrollS > clientHeight + 100) {
handleGetMore() loadMorePosts()
} }
}) }, 500)
} )
useEffect(() => { useEffect(() => {
window.addEventListener('scroll', scrollTrigger) window.addEventListener('scroll', scrollTrigger)
return () => { return () => {
window.removeEventListener('scroll', scrollTrigger) window.removeEventListener('scroll', scrollTrigger)
} }
}, []) })
// 根据当前页和每页文章数截取应该显示的文章
useEffect(() => {
const startIndex = (page - 1) * postsPerPage;
const endIndex = startIndex + postsPerPage;
const postsToShow = posts.slice(startIndex, endIndex);
const columns = 3; // 假设有3列
// 重新排列文章,保证列优先顺序
const newFilterPosts = [];
for (let col = 0; col < columns; col++) {
for (let i = col; i < postsToShow.length; i += columns) {
newFilterPosts.push(postsToShow[i]);
}
}
setFilterPostsGroups((prev) => [...prev, newFilterPosts]);
}, [posts, page]);
if (!posts || posts.length === 0) { if (!posts || posts.length === 0) {
return <BlogPostListEmpty /> return <BlogPostListEmpty />;
} else { } else {
return ( return (
<div id='posts-wrapper' ref={targetRef} className='grid-container'> <div ref={targetRef}>
{/* 文章列表 */} {filterPostsGroups.map((group, groupIndex) => (
{postsToShow?.map(post => ( <div key={groupIndex} id="posts-wrapper" className="grid-container mb-10">
<div {group.map((post) => (
key={post.id} <div
className='grid-item justify-center flex' key={post.id}
style={{ breakInside: 'avoid' }}> className="grid-item justify-center flex"
<BlogCard style={{ breakInside: 'avoid' }}
index={posts.indexOf(post)} >
key={post.id} <BlogCard key={post.id} post={post} showAnimate={groupIndex > 0}/>
post={post} </div>
siteInfo={siteInfo} ))}
/>
</div> </div>
))} ))}
<div <div
className='w-full my-4 py-4 text-center cursor-pointer ' className="w-full my-4 py-4 text-center cursor-pointer"
onClick={handleGetMore}> onClick={loadMorePosts}
{' '} >
{hasMore ? locale.COMMON.MORE : `${locale.COMMON.NO_MORE} 😰`}{' '} {page < totalPages ? locale.COMMON.MORE : `${locale.COMMON.NO_MORE} 😰`}
</div> </div>
</div> </div>
) );
} }
} };
export default BlogListScroll;
export default BlogListScroll

View File

@@ -114,12 +114,13 @@ const LayoutIndex = props => {
* @param {*} props * @param {*} props
*/ */
const LayoutPostList = props => { const LayoutPostList = props => {
const POST_LIST_STYLE = siteConfig('POST_LIST_STYLE')
return ( return (
<> <>
<div className='w-full p-2'> <div className='w-full p-2'>
<WWAds className='w-full' orientation='horizontal' /> <WWAds className='w-full' orientation='horizontal' />
</div> </div>
{siteConfig('POST_LIST_STYLE') === 'page' ? ( { POST_LIST_STYLE=== 'page' ? (
<BlogListPage {...props} /> <BlogListPage {...props} />
) : ( ) : (
<BlogListScroll {...props} /> <BlogListScroll {...props} />

View File

@@ -44,7 +44,16 @@ const Style = () => {
column-gap: .5rem; column-gap: .5rem;
} }
} }
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 10px;
padding: 10px;
}
`}</style> `}</style>
} }
export { Style } export { Style }

View File

@@ -9,7 +9,7 @@ export const BlogListScroll = props => {
const { posts } = props const { posts } = props
const { locale, NOTION_CONFIG } = useGlobal() const { locale, NOTION_CONFIG } = useGlobal()
const [page, updatePage] = useState(1) const [page, updatePage] = useState(1)
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
let hasMore = false let hasMore = false
const postsToShow = const postsToShow =

View File

@@ -14,7 +14,7 @@ import PaginationNumber from './PaginationNumber'
*/ */
const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE) const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
const showPagination = postCount >= POSTS_PER_PAGE const showPagination = postCount >= POSTS_PER_PAGE
if (!posts || posts.length === 0 || page > totalPage) { if (!posts || posts.length === 0 || page > totalPage) {

View File

@@ -21,7 +21,7 @@ const BlogPostListScroll = ({
}) => { }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const [page, updatePage] = useState(1) const [page, updatePage] = useState(1)
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const postsToShow = getListByPage(posts, page, POSTS_PER_PAGE) const postsToShow = getListByPage(posts, page, POSTS_PER_PAGE)
let hasMore = false let hasMore = false

View File

@@ -14,7 +14,7 @@ import PaginationNumber from './PaginationNumber'
*/ */
const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE) const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
const showPagination = postCount >= POSTS_PER_PAGE const showPagination = postCount >= POSTS_PER_PAGE
if (!posts || posts.length === 0 || page > totalPage) { if (!posts || posts.length === 0 || page > totalPage) {

View File

@@ -21,7 +21,7 @@ const BlogPostListScroll = ({
}) => { }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const [page, updatePage] = useState(1) const [page, updatePage] = useState(1)
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const postsToShow = getListByPage(posts, page, POSTS_PER_PAGE) const postsToShow = getListByPage(posts, page, POSTS_PER_PAGE)
let hasMore = false let hasMore = false

View File

@@ -14,7 +14,7 @@ import PaginationSimple from './PaginationSimple'
*/ */
const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE) const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
const showPagination = postCount >= POSTS_PER_PAGE const showPagination = postCount >= POSTS_PER_PAGE
if (!posts || posts.length === 0 || page > totalPage) { if (!posts || posts.length === 0 || page > totalPage) {

View File

@@ -21,7 +21,7 @@ const BlogPostListScroll = ({
siteInfo siteInfo
}) => { }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const [page, updatePage] = useState(1) const [page, updatePage] = useState(1)
const postsToShow = getListByPage(posts, page, POSTS_PER_PAGE) const postsToShow = getListByPage(posts, page, POSTS_PER_PAGE)
// 监听滚动 // 监听滚动

View File

@@ -14,7 +14,7 @@ import PaginationSimple from './PaginationSimple'
*/ */
const BlogPostListPage = ({ page = 1, posts = [], postCount }) => { const BlogPostListPage = ({ page = 1, posts = [], postCount }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE) const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
if (!posts || posts.length === 0) { if (!posts || posts.length === 0) {

View File

@@ -15,7 +15,7 @@ import BlogPostListEmpty from './BlogPostListEmpty'
*/ */
const BlogPostListScroll = ({ posts = [], currentSearch }) => { const BlogPostListScroll = ({ posts = [], currentSearch }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const [page, updatePage] = useState(1) const [page, updatePage] = useState(1)
const router = useRouter() const router = useRouter()
let filteredPosts = Object.assign(posts) let filteredPosts = Object.assign(posts)

View File

@@ -7,7 +7,7 @@ import PaginationNumber from './PaginationNumber'
export const BlogListPage = props => { export const BlogListPage = props => {
const { page = 1, posts, postCount } = props const { page = 1, posts, postCount } = props
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE) const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
const showPageCover = siteConfig('MOVIE_POST_LIST_COVER', null, CONFIG) const showPageCover = siteConfig('MOVIE_POST_LIST_COVER', null, CONFIG)

View File

@@ -13,7 +13,7 @@ import PaginationSimple from './PaginationSimple'
*/ */
const BlogPostListPage = ({ page = 1, posts = [], postCount }) => { const BlogPostListPage = ({ page = 1, posts = [], postCount }) => {
const totalPage = Math.ceil( const totalPage = Math.ceil(
postCount / parseInt(siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG)) postCount / parseInt(siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG))
) )
if (!posts || posts.length === 0) { if (!posts || posts.length === 0) {

View File

@@ -16,8 +16,6 @@ const NavPostItem = props => {
const toggleOpenSubMenu = () => { const toggleOpenSubMenu = () => {
changeIsOpen(!isOpen) changeIsOpen(!isOpen)
} }
console.log('group::')
console.log(group)
if (group?.category) { if (group?.category) {
return ( return (

View File

@@ -14,7 +14,7 @@ import PaginationNumber from './PaginationNumber'
*/ */
const BlogPostListPage = ({ page = 1, posts = [], postCount }) => { const BlogPostListPage = ({ page = 1, posts = [], postCount }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE) const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
if (!posts || posts.length === 0) { if (!posts || posts.length === 0) {

View File

@@ -19,7 +19,7 @@ const BlogPostListScroll = ({
showSummary = siteConfig('NEXT_POST_LIST_SUMMARY', null, CONFIG) showSummary = siteConfig('NEXT_POST_LIST_SUMMARY', null, CONFIG)
}) => { }) => {
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const [page, updatePage] = useState(1) const [page, updatePage] = useState(1)
const postsToShow = getPostByPage(page, posts, POSTS_PER_PAGE) const postsToShow = getPostByPage(page, posts, POSTS_PER_PAGE)

View File

@@ -9,7 +9,7 @@ export const BlogListPage = props => {
const { locale } = useGlobal() const { locale } = useGlobal()
const router = useRouter() const router = useRouter()
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE) const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
const currentPage = +page const currentPage = +page

View File

@@ -10,7 +10,7 @@ export const BlogListPage = props => {
const { locale } = useGlobal() const { locale } = useGlobal()
const router = useRouter() const router = useRouter()
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE) const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
const currentPage = +page const currentPage = +page

View File

@@ -15,7 +15,7 @@ export default function BlogListPage(props) {
const { page = 1, posts, postCount } = props const { page = 1, posts, postCount } = props
const router = useRouter() const router = useRouter()
const { NOTION_CONFIG } = useGlobal() const { NOTION_CONFIG } = useGlobal()
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
const totalPage = Math.ceil(postCount / POSTS_PER_PAGE) const totalPage = Math.ceil(postCount / POSTS_PER_PAGE)
const currentPage = +page const currentPage = +page

View File

@@ -13,7 +13,7 @@ export default function BlogListScroll(props) {
const { posts } = props const { posts } = props
const { locale, NOTION_CONFIG } = useGlobal() const { locale, NOTION_CONFIG } = useGlobal()
const [page, updatePage] = useState(1) const [page, updatePage] = useState(1)
const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', 12, NOTION_CONFIG) const POSTS_PER_PAGE = siteConfig('POSTS_PER_PAGE', null, NOTION_CONFIG)
let hasMore = false let hasMore = false
const postsToShow = posts const postsToShow = posts
? Object.assign(posts).slice(0, POSTS_PER_PAGE * page) ? Object.assign(posts).slice(0, POSTS_PER_PAGE * page)