{post?.title}
- -{post?.title}
+
@@ -36,7 +44,6 @@ const BlogPostCard = ({ post, showSummary }) => {
components={{
equation: Equation,
code: Code,
- collectionRow: CollectionRow,
collection: Collection
}}
/>
diff --git a/themes/Medium/components/BlogPostListPage.js b/themes/Medium/components/BlogPostListPage.js
index fe91b9b0..bac8ab88 100644
--- a/themes/Medium/components/BlogPostListPage.js
+++ b/themes/Medium/components/BlogPostListPage.js
@@ -2,6 +2,7 @@ import BlogPostCard from './BlogPostCard'
import BLOG from '@/blog.config'
import BlogPostListEmpty from './BlogPostListEmpty'
import PaginationSimple from './PaginationSimple'
+import { useRouter } from 'next/router'
/**
* 文章列表分页表格
diff --git a/themes/Medium/components/BlogPostListScroll.js b/themes/Medium/components/BlogPostListScroll.js
new file mode 100644
index 00000000..1b2334cc
--- /dev/null
+++ b/themes/Medium/components/BlogPostListScroll.js
@@ -0,0 +1,106 @@
+import BLOG from '@/blog.config'
+import BlogPostCard from './BlogPostCard'
+import BlogPostListEmpty from './BlogPostListEmpty'
+import { useGlobal } from '@/lib/global'
+import throttle from 'lodash.throttle'
+import React, { useCallback, useEffect, useRef, useState } from 'react'
+import { useRouter } from 'next/router'
+
+/**
+ * 博客列表滚动分页
+ * @param posts 所有文章
+ * @param tags 所有标签
+ * @returns {JSX.Element}
+ * @constructor
+ */
+const BlogPostListScroll = ({ posts = [], currentSearch }) => {
+ const postsPerPage = BLOG.POSTS_PER_PAGE
+ const [page, updatePage] = useState(1)
+ let filteredPosts = Object.assign(posts)
+ const searchKey = getSearchKey()
+ if (searchKey) {
+ filteredPosts = posts.filter(post => {
+ const tagContent = post.tags ? post.tags.join(' ') : ''
+ const searchContent = post.title + post.summary + tagContent
+ return searchContent.toLowerCase().includes(searchKey.toLowerCase())
+ })
+ }
+ const postsToShow = getPostByPage(page, filteredPosts, postsPerPage)
+
+ let hasMore = false
+ if (filteredPosts) {
+ const totalCount = filteredPosts.length
+ hasMore = page * postsPerPage < totalCount
+ }
+
+ const handleGetMore = () => {
+ if (!hasMore) return
+ updatePage(page + 1)
+ }
+
+ // 监听滚动自动分页加载
+ const scrollTrigger = useCallback(throttle(() => {
+ const scrollS = window.scrollY + window.outerHeight
+ const clientHeight = targetRef ? (targetRef.current ? (targetRef.current.clientHeight) : 0) : 0
+ if (scrollS > clientHeight + 100) {
+ handleGetMore()
+ }
+ }, 500))
+
+ // 监听滚动
+ useEffect(() => {
+ window.addEventListener('scroll', scrollTrigger)
+ return () => {
+ window.removeEventListener('scroll', scrollTrigger)
+ }
+ })
+
+ const targetRef = useRef(null)
+ const { locale } = useGlobal()
+
+ if (!postsToShow || postsToShow.length === 0) {
+ return
| [notion-next.tangly1024.com](https://notion-next.tangly1024.com) |
+|
| [notion-medium.tangly1024.com](https://notion-medium.tangly1024.com/) |
+|
| [notion-hexo.tangly1024.com](http://notion-hexo.tangly1024.com/) |
+|
| [notion-fukasawa.tangly1024.com](https://notion-fukasawa.tangly1024.com/) |
+
+
## 更新日志
请移步 [更新文档](https://docs.tangly1024.com/zh/changelog)查看
@@ -66,13 +87,9 @@
```bash
yarn # 安装依赖
-
yarn run dev # 本地开发
-
yarn run build # 本地打包编译
-
yarn run start # 本地启动NextJS服务
-
```
## 引用技术
@@ -83,9 +100,6 @@ yarn run start # 本地启动NextJS服务
- **评论**: Gitalk, Cusdis, Utterances
- **图标**:[fontawesome](https://fontawesome.com/v5.15/icons?d=gallery)
-## 页面样式主题
-正在开发中..将支持配置文件切换主题
-
## License
The MIT License.
diff --git a/blog.config.js b/blog.config.js
index a6f06c4f..6c22adf3 100644
--- a/blog.config.js
+++ b/blog.config.js
@@ -11,7 +11,7 @@ const BLOG = {
LANG: 'zh-CN', // e.g 'zh-CN','en-US' see /lib/lang.js for more.
SINCE: 2021, // e.g if leave this empty, current year will be used.
- BEI_AN: '', // 备案号 闽ICP备XXXXXXX
+ BEI_AN: process.env.NEXT_PUBLIC_BEI_AN || '', // 备案号 闽ICP备XXXXXXX
APPEARANCE: 'auto', // ['light', 'dark', 'auto'],
FONT: 'font-serif tracking-wider subpixel-antialiased', // 文章字体 ['font-sans', 'font-serif', 'font-mono'] @see https://www.tailwindcss.cn/docs/font-family
BACKGROUND_LIGHT: '#eeeeee', // use hex value, don't forget '#' e.g #fffefc
diff --git a/components/Comment.js b/components/Comment.js
index 9b47d752..772a3776 100644
--- a/components/Comment.js
+++ b/components/Comment.js
@@ -23,7 +23,7 @@ const Comment = ({ frontMatter }) => {
const router = useRouter()
const { locale } = useGlobal()
return (
-