From 5cd3824827dff089b106c2191cbc882c17d7514c Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 25 Apr 2022 11:16:21 +0800 Subject: [PATCH 1/7] =?UTF-8?q?hexo:ipad=E7=AB=AF=E8=BE=B9=E7=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/LayoutBase.js | 4 ++-- themes/hexo/LayoutSlug.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/hexo/LayoutBase.js b/themes/hexo/LayoutBase.js index 6d78abee..39a96c21 100644 --- a/themes/hexo/LayoutBase.js +++ b/themes/hexo/LayoutBase.js @@ -59,12 +59,12 @@ const LayoutBase = props => { {headerSlot} -
+
-
+
{onLoading ? : children}
diff --git a/themes/hexo/LayoutSlug.js b/themes/hexo/LayoutSlug.js index ee3143cf..e914a191 100644 --- a/themes/hexo/LayoutSlug.js +++ b/themes/hexo/LayoutSlug.js @@ -54,7 +54,7 @@ export const LayoutSlug = props => {
{lock && } - {!lock &&
+ {!lock &&
{/* Notion文章主体 */} From ca2fd3e5a9029014b288406787df29578bc97269 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 25 Apr 2022 11:27:33 +0800 Subject: [PATCH 2/7] =?UTF-8?q?hexo:=E8=BE=B9=E8=B7=9D=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/LayoutBase.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/hexo/LayoutBase.js b/themes/hexo/LayoutBase.js index 39a96c21..d7fdbf2b 100644 --- a/themes/hexo/LayoutBase.js +++ b/themes/hexo/LayoutBase.js @@ -59,7 +59,7 @@ const LayoutBase = props => { {headerSlot} -
+
Date: Mon, 25 Apr 2022 11:27:43 +0800 Subject: [PATCH 3/7] =?UTF-8?q?hexo:=20=E5=9B=BE=E7=89=87=E9=AB=98?= =?UTF-8?q?=E5=BA=A6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/components/BlogPostCard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js index ea95f425..a11af155 100644 --- a/themes/hexo/components/BlogPostCard.js +++ b/themes/hexo/components/BlogPostCard.js @@ -85,7 +85,7 @@ const BlogPostCard = ({ post, showSummary }) => { {post.title} {/* {post.title} */}
From f4c940a0afccbe3d6a854e51b7fa5ad815c12364 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 25 Apr 2022 11:27:56 +0800 Subject: [PATCH 4/7] =?UTF-8?q?fukasawa=EF=BC=9A=20=E5=8D=A1=E7=89=87?= =?UTF-8?q?=E5=88=97=E6=95=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/fukasawa/components/BlogListPage.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/fukasawa/components/BlogListPage.js b/themes/fukasawa/components/BlogListPage.js index a418ff47..04ef2b47 100644 --- a/themes/fukasawa/components/BlogListPage.js +++ b/themes/fukasawa/components/BlogListPage.js @@ -20,6 +20,8 @@ const BlogListPage = ({ page = 1, posts = [], postCount }) => { function updateCol() { if (window.outerWidth > 1200) { changeCol(3) + } else if (window.outerWidth > 900) { + changeCol(2) } else { changeCol(1) } From 87440ea140f9ca9a4914696a4ebf3a16315bf07c Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 25 Apr 2022 16:01:48 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=86=85=E9=83=A8=E5=BC=95=E7=94=A8?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E5=8F=AF=E4=BB=A5=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/NotionPage.js | 8 +++++++- lib/utils.js | 11 ++++++++++- pages/article/[slug].js | 7 +++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/components/NotionPage.js b/components/NotionPage.js index 0930eef4..03b1f1eb 100644 --- a/components/NotionPage.js +++ b/components/NotionPage.js @@ -75,8 +75,14 @@ const NotionPage = ({ post }) => {
} +/** + * 将id映射成博文内部链接。 + * @param {*} id + * @returns + */ const mapPageUrl = id => { - return 'https://www.notion.so/' + id.replace(/-/g, '') + // return 'https://www.notion.so/' + id.replace(/-/g, '') + return '/article/' + id.replace(/-/g, '') } function getMediumZoomMargin() { diff --git a/lib/utils.js b/lib/utils.js index be47e17f..be9db197 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -64,10 +64,19 @@ export function mergeDeep(target, ...sources) { } /** - * 对象检查 + * 是否对象 * @param item * @returns {boolean} */ export function isObject(item) { return (item && typeof item === 'object' && !Array.isArray(item)) } + +/** + * 是否可迭代 + * @param {*} obj + * @returns + */ +export function isIterable(obj) { + return obj != null && typeof obj[Symbol.iterator] === 'function' +} diff --git a/pages/article/[slug].js b/pages/article/[slug].js index b190738d..538cbc90 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -5,6 +5,7 @@ import { useGlobal } from '@/lib/global' import * as ThemeMap from '@/themes' import { useEffect, useState } from 'react' import { useRouter } from 'next/router' +import { idToUuid } from 'notion-utils' /** * 根据notion的slug访问页面 @@ -30,7 +31,7 @@ const Slug = props => { } }, 3000) }) - const meta = { title: `${props?.siteInfo?.title} | loading` } + const meta = { title: `${props?.siteInfo?.title || BLOG.TITLE} | loading` } return } @@ -92,7 +93,9 @@ export async function getStaticProps({ params: { slug } }) { const from = `slug-props-${slug}` const props = await getGlobalNotionData({ from, pageType: ['Post'] }) const allPosts = props.allPosts - props.post = props.allPosts.find(p => p.slug === slug) + props.post = props.allPosts.find((p) => { + return p.slug === slug || p.id === idToUuid(slug) + }) if (!props.post) { return { props, revalidate: 1 } } From 888496b3cc2c862507b5efcd2a7157fbb49ed3a1 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 25 Apr 2022 16:02:04 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A9=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=BC=96=E8=AF=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/getAllCategories.js | 16 ++++++++++------ lib/notion/getAllTags.js | 17 ++++++++++------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/notion/getAllCategories.js b/lib/notion/getAllCategories.js index 61aab49c..b9a543d8 100644 --- a/lib/notion/getAllCategories.js +++ b/lib/notion/getAllCategories.js @@ -1,9 +1,11 @@ +import { isIterable } from '../utils' + /** * 获取所有文章的分类 * @param allPosts * @returns {Promise<{}|*[]>} */ -export async function getAllCategories ({ allPosts, categoryOptions, sliceCount = 0 }) { +export async function getAllCategories({ allPosts, categoryOptions, sliceCount = 0 }) { if (!allPosts || !categoryOptions) { return [] } @@ -19,12 +21,14 @@ export async function getAllCategories ({ allPosts, categoryOptions, sliceCount } }) const list = [] - categoryOptions.forEach(c => { - const count = categoryObj[c.value] - if (count) { - list.push({ id: c.id, name: c.value, color: c.color, count }) + if (isIterable(categoryOptions)) { + for (const c of categoryOptions) { + const count = categoryObj[c.value] + if (count) { + list.push({ id: c.id, name: c.value, color: c.color, count }) + } } - }) + } // 按照数量排序 // list.sort((a, b) => b.count - a.count) diff --git a/lib/notion/getAllTags.js b/lib/notion/getAllTags.js index 3ac01f54..174055d1 100644 --- a/lib/notion/getAllTags.js +++ b/lib/notion/getAllTags.js @@ -1,3 +1,4 @@ +import { isIterable } from '../utils' /** * 获取所有文章的标签 @@ -6,7 +7,7 @@ * @param tagOptions tags的下拉选项 * @returns {Promise<{}|*[]>} */ -export async function getAllTags ({ allPosts, sliceCount = 0, tagOptions }) { +export async function getAllTags({ allPosts, sliceCount = 0, tagOptions }) { if (!allPosts || !tagOptions) { return [] } @@ -22,12 +23,14 @@ export async function getAllTags ({ allPosts, sliceCount = 0, tagOptions }) { } }) const list = [] - tagOptions.forEach(c => { - const count = tagObj[c.value] - if (count) { - list.push({ id: c.id, name: c.value, color: c.color, count }) - } - }) + if (isIterable(tagOptions)) { + tagOptions.forEach(c => { + const count = tagObj[c.value] + if (count) { + list.push({ id: c.id, name: c.value, color: c.color, count }) + } + }) + } // 按照数量排序 // list.sort((a, b) => b.count - a.count) From c751c17424d840c7e12d4b362e4d12b441226055 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 25 Apr 2022 16:22:28 +0800 Subject: [PATCH 7/7] =?UTF-8?q?page-icon=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- styles/notion.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles/notion.css b/styles/notion.css index d42d3b11..b176aed2 100644 --- a/styles/notion.css +++ b/styles/notion.css @@ -1601,7 +1601,7 @@ svg.notion-page-icon { } svg.notion-page-icon { - @apply hidden; + /* @apply hidden;*/ } svg + .notion-page-title-text {