From 9d6e6d76d367f35e8b7707d6e05e6167d7ddf195 Mon Sep 17 00:00:00 2001
From: Femoon <839242981@qq.com>
Date: Sat, 21 Oct 2023 15:55:50 +0800
Subject: [PATCH 01/72] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20Medium=20?=
=?UTF-8?q?=E4=B8=BB=E9=A2=98=E9=A6=96=E9=A1=B5=E6=96=87=E7=AB=A0=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E6=97=A0=E5=9B=BE=E7=89=87=20AOS=20=E5=8A=A8=E7=94=BB?=
=?UTF-8?q?=E5=BC=82=E5=B8=B8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/LazyImage.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/components/LazyImage.js b/components/LazyImage.js
index 4556bd0d..d878ddb1 100644
--- a/components/LazyImage.js
+++ b/components/LazyImage.js
@@ -60,6 +60,7 @@ export default function LazyImage({
ref: imageRef,
src: imageLoaded ? src : placeholderSrc,
alt: alt,
+ style: src ? style : { height: '0px', ...style },
onLoad: handleImageLoad
}
From 000077ca1ac4a2b27d9c6f7c8780ed3acb743c04 Mon Sep 17 00:00:00 2001
From: Femoon <839242981@qq.com>
Date: Mon, 23 Oct 2023 10:03:40 +0800
Subject: [PATCH 02/72] =?UTF-8?q?fix:=20=E6=94=B9=E7=94=A8=20style=20?=
=?UTF-8?q?=E4=BC=A0=20height?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/LazyImage.js | 1 -
themes/medium/components/BlogPostCard.js | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/components/LazyImage.js b/components/LazyImage.js
index d878ddb1..4556bd0d 100644
--- a/components/LazyImage.js
+++ b/components/LazyImage.js
@@ -60,7 +60,6 @@ export default function LazyImage({
ref: imageRef,
src: imageLoaded ? src : placeholderSrc,
alt: alt,
- style: src ? style : { height: '0px', ...style },
onLoad: handleImageLoad
}
diff --git a/themes/medium/components/BlogPostCard.js b/themes/medium/components/BlogPostCard.js
index 273660b0..16a963e6 100644
--- a/themes/medium/components/BlogPostCard.js
+++ b/themes/medium/components/BlogPostCard.js
@@ -31,7 +31,7 @@ const BlogPostCard = ({ post, showSummary }) => {
}>
{CONFIG.POST_LIST_COVER &&
-
+
}
{post.title}
From 608cc8991b1e80f24685e52d9ed616b728a1bf3b Mon Sep 17 00:00:00 2001
From: tangly1024
Date: Sun, 29 Oct 2023 11:21:16 +0800
Subject: [PATCH 03/72] =?UTF-8?q?=E5=A4=9A=E7=BA=A7slug-bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/notion/getPageProperties.js | 2 +
pages/[prefix]/[slug]/[...suffix].js | 113 ++++++++++++++++++
pages/[prefix]/{[slug].js => [slug]/index.js} | 3 +-
pages/[prefix]/index.js | 1 +
4 files changed, 118 insertions(+), 1 deletion(-)
create mode 100644 pages/[prefix]/[slug]/[...suffix].js
rename pages/[prefix]/{[slug].js => [slug]/index.js} (96%)
diff --git a/lib/notion/getPageProperties.js b/lib/notion/getPageProperties.js
index 8d3add33..ddf47f3e 100644
--- a/lib/notion/getPageProperties.js
+++ b/lib/notion/getPageProperties.js
@@ -135,6 +135,8 @@ function mapProperties(properties) {
/**
* 获取自定义URL
+ * 可以根据变量生成URL
+ * 支持:%year%/%month%/%day%/%slug%
* @param {*} postProperties
* @returns
*/
diff --git a/pages/[prefix]/[slug]/[...suffix].js b/pages/[prefix]/[slug]/[...suffix].js
new file mode 100644
index 00000000..67f099d7
--- /dev/null
+++ b/pages/[prefix]/[slug]/[...suffix].js
@@ -0,0 +1,113 @@
+import BLOG from '@/blog.config'
+import { getPostBlocks } from '@/lib/notion'
+import { getGlobalData } from '@/lib/notion/getNotionData'
+import { idToUuid } from 'notion-utils'
+import { getNotion } from '@/lib/notion/getNotion'
+import Slug, { getRecommendPost } from '..'
+import { uploadDataToAlgolia } from '@/lib/algolia'
+
+/**
+ * 根据notion的slug访问页面
+ * 解析三级以上目录 /article/2023/10/29/test
+ * @param {*} props
+ * @returns
+ */
+const PrefixSlug = props => {
+ return
+}
+
+/**
+ * 编译渲染页面路径
+ * @returns
+ */
+export async function getStaticPaths() {
+ if (!BLOG.isProd) {
+ return {
+ paths: [],
+ fallback: true
+ }
+ }
+
+ const from = 'slug-paths'
+ const { allPages } = await getGlobalData({ from })
+ return {
+ paths: allPages?.filter(row => hasMultipleSlashes(row.slug) && row.type.indexOf('Menu') < 0).map(row => ({ params: { prefix: row.slug.split('/')[0], slug: row.slug.split('/')[1], suffix: row.slug.split('/').slice(1) } })),
+ fallback: true
+ }
+}
+
+/**
+ * 抓取页面数据
+ * @param {*} param0
+ * @returns
+ */
+export async function getStaticProps({ params: { prefix, slug, suffix } }) {
+ let fullSlug = prefix + '/' + slug + '/' + suffix.join('/')
+ if (JSON.parse(BLOG.PSEUDO_STATIC)) {
+ if (!fullSlug.endsWith('.html')) {
+ fullSlug += '.html'
+ }
+ }
+ const from = `slug-props-${fullSlug}`
+ const props = await getGlobalData({ from })
+ // 在列表内查找文章
+ props.post = props?.allPages?.find((p) => {
+ return p.slug === fullSlug || p.id === idToUuid(fullSlug)
+ })
+
+ // 处理非列表内文章的内信息
+ if (!props?.post) {
+ const pageId = fullSlug.slice(-1)[0]
+ if (pageId.length >= 32) {
+ const post = await getNotion(pageId)
+ props.post = post
+ }
+ }
+
+ // 无法获取文章
+ if (!props?.post) {
+ props.post = null
+ return { props, revalidate: parseInt(BLOG.NEXT_REVALIDATE_SECOND) }
+ }
+
+ // 文章内容加载
+ if (!props?.posts?.blockMap) {
+ props.post.blockMap = await getPostBlocks(props.post.id, from)
+ }
+ // 生成全文索引 && JSON.parse(BLOG.ALGOLIA_RECREATE_DATA)
+ if (BLOG.ALGOLIA_APP_ID) {
+ uploadDataToAlgolia(props?.post)
+ }
+
+ // 推荐关联文章处理
+ const allPosts = props.allPages?.filter(page => page.type === 'Post' && page.status === 'Published')
+ if (allPosts && allPosts.length > 0) {
+ const index = allPosts.indexOf(props.post)
+ props.prev = allPosts.slice(index - 1, index)[0] ?? allPosts.slice(-1)[0]
+ props.next = allPosts.slice(index + 1, index + 2)[0] ?? allPosts[0]
+ props.recommendPosts = getRecommendPost(props.post, allPosts, BLOG.POST_RECOMMEND_COUNT)
+ } else {
+ props.prev = null
+ props.next = null
+ props.recommendPosts = []
+ }
+
+ delete props.allPages
+ return {
+ props,
+ revalidate: parseInt(BLOG.NEXT_REVALIDATE_SECOND)
+ }
+}
+
+/**
+ * 判断是否包含两个以上的 /
+ * @param {*} str
+ * @returns
+ */
+function hasMultipleSlashes(str) {
+ const regex = /\/+/g; // 创建正则表达式,匹配所有的斜杠符号
+ const matches = str.match(regex); // 在字符串中找到所有匹配的斜杠符号
+ return matches && matches.length >= 2; // 判断匹配的斜杠符号数量是否大于等于2
+}
+
+export default PrefixSlug
diff --git a/pages/[prefix]/[slug].js b/pages/[prefix]/[slug]/index.js
similarity index 96%
rename from pages/[prefix]/[slug].js
rename to pages/[prefix]/[slug]/index.js
index 2beae09c..4571b791 100644
--- a/pages/[prefix]/[slug].js
+++ b/pages/[prefix]/[slug]/index.js
@@ -3,11 +3,12 @@ import { getPostBlocks } from '@/lib/notion'
import { getGlobalData } from '@/lib/notion/getNotionData'
import { idToUuid } from 'notion-utils'
import { getNotion } from '@/lib/notion/getNotion'
-import Slug, { getRecommendPost } from '.'
+import Slug, { getRecommendPost } from '..'
import { uploadDataToAlgolia } from '@/lib/algolia'
/**
* 根据notion的slug访问页面
+ * 解析二级目录 /article/about
* @param {*} props
* @returns
*/
diff --git a/pages/[prefix]/index.js b/pages/[prefix]/index.js
index ecfea4e1..6fa5d47b 100644
--- a/pages/[prefix]/index.js
+++ b/pages/[prefix]/index.js
@@ -13,6 +13,7 @@ import { uploadDataToAlgolia } from '@/lib/algolia'
/**
* 根据notion的slug访问页面
+ * 只解析一级目录例如 /about
* @param {*} props
* @returns
*/
From 0d0c1ac9ea7265eeaee5f2b80343fcc85a859c71 Mon Sep 17 00:00:00 2001
From: tangly1024
Date: Sun, 29 Oct 2023 13:25:17 +0800
Subject: [PATCH 04/72] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A7=86=E9=A2=91?=
=?UTF-8?q?=E6=97=A0=E6=B3=95=E6=92=AD=E6=94=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/notion/getPostBlocks.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/notion/getPostBlocks.js b/lib/notion/getPostBlocks.js
index a9e3a757..809dfe7a 100644
--- a/lib/notion/getPostBlocks.js
+++ b/lib/notion/getPostBlocks.js
@@ -102,7 +102,7 @@ function filterPostBlocks(id, pageBlock, slice) {
}
// 如果是文件,或嵌入式PDF,需要重新加密签名
- if ((b?.value?.type === 'file' || b?.value?.type === 'pdf') && b?.value?.properties?.source?.[0][0]) {
+ if ((b?.value?.type === 'file' || b?.value?.type === 'pdf' || b?.value?.type === 'video') && b?.value?.properties?.source?.[0][0]) {
const oldUrl = b?.value?.properties?.source?.[0][0]
const newUrl = `https://notion.so/signed/${encodeURIComponent(oldUrl)}?table=block&id=${b?.value?.id}`
b.value.properties.source[0][0] = newUrl
From fd29df3b26211aad04a9e6462cae038d7006e826 Mon Sep 17 00:00:00 2001
From: tangly1024
Date: Sun, 29 Oct 2023 13:26:43 +0800
Subject: [PATCH 05/72] 4.0.17
---
.env.local | 2 +-
package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/.env.local b/.env.local
index 5df7065b..8fb4ae71 100644
--- a/.env.local
+++ b/.env.local
@@ -1,2 +1,2 @@
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
-NEXT_PUBLIC_VERSION=4.0.16
\ No newline at end of file
+NEXT_PUBLIC_VERSION=4.0.17
\ No newline at end of file
diff --git a/package.json b/package.json
index 1c24ce6f..586f98cf 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "notion-next",
- "version": "4.0.16",
+ "version": "4.0.17",
"homepage": "https://github.com/tangly1024/NotionNext.git",
"license": "MIT",
"repository": {
From 61f014e60ff60ab395caa3eb6be2000110918280 Mon Sep 17 00:00:00 2001
From: expoli <31023767+expoli@users.noreply.github.com>
Date: Sun, 29 Oct 2023 19:42:38 +0800
Subject: [PATCH 06/72] [fix] key not exist error
---
themes/hexo/components/MenuGroupCard.js | 6 ++++++
themes/hexo/components/MenuListSide.js | 6 ++++++
themes/hexo/components/MenuListTop.js | 6 ++++++
3 files changed, 18 insertions(+)
diff --git a/themes/hexo/components/MenuGroupCard.js b/themes/hexo/components/MenuGroupCard.js
index 574a8e5b..5be22e2b 100644
--- a/themes/hexo/components/MenuGroupCard.js
+++ b/themes/hexo/components/MenuGroupCard.js
@@ -16,6 +16,12 @@ const MenuGroupCard = (props) => {
{ name: locale.COMMON.TAGS, to: '/tag', slot: tagSlot, show: CONFIG.MENU_TAG }
]
+ for (let i = 0; i < links.length; i++) {
+ if (links[i].id !== i) {
+ links[i].id = i
+ }
+ }
+
return (