From 91fac55b421f38844525f28fc45f9a985892da40 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 31 Jul 2023 20:46:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=BB=E9=A2=98=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog.config.js b/blog.config.js index fab696b8..d1a0d961 100644 --- a/blog.config.js +++ b/blog.config.js @@ -5,7 +5,7 @@ const BLOG = { process.env.NOTION_PAGE_ID || '02ab3b8678004aa69e9e415905ef32a5', PSEUDO_STATIC: process.env.NEXT_PUBLIC_PSEUDO_STATIC || false, // 伪静态路径,开启后所有文章URL都以 .html 结尾。 NEXT_REVALIDATE_SECOND: process.env.NEXT_PUBLIC_REVALIDATE_SECOND || 5, // 更新内容缓存间隔 单位(秒);即每个页面有5秒的纯静态期、此期间无论多少次访问都不会抓取notion数据;调大该值有助于节省Vercel资源、同时提升访问速率,但也会使文章更新有延迟。 - THEME: process.env.NEXT_PUBLIC_THEME || 'hexo', // 主题, 支持 ['next','hexo',"fukasawa','medium','example','matery','gitbook','simple'] @see https://preview.tangly1024.com + THEME: process.env.NEXT_PUBLIC_THEME || 'hexo', // 当前主题,在themes文件夹下可找到所有支持的主题;主题名称就是文件夹名,例如 example,fukasawa,gitbook,heo,hexo,landing,matery,medium,next,nobelium,plog,simple THEME_SWITCH: process.env.NEXT_PUBLIC_THEME_SWITCH || false, // 是否显示切换主题按钮 LANG: process.env.NEXT_PUBLIC_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. From 570ab5a13c3e1fb7718af77efbb6d64bf1fa1a40 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Tue, 1 Aug 2023 14:17:30 +0800 Subject: [PATCH 2/3] fix/build-nobelium --- lib/utils.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index e13b192f..dc7cbeb6 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -112,24 +112,32 @@ export function isIterable(obj) { return obj != null && typeof obj[Symbol.iterator] === 'function' } +/** + * 深拷贝对象 + * 根据源对象类型深度复制,支持object和array + * @param {*} obj + * @returns + */ export function deepClone(obj) { - const newObj = Array.isArray(obj) ? [] : {} - if (obj && typeof obj === 'object') { + if (Array.isArray(obj)) { + // If obj is an array, create a new array and deep clone each element + return obj.map(item => deepClone(item)) + } else if (obj && typeof obj === 'object') { + const newObj = {} for (const key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { - if (obj[key] instanceof Date) { // 判断属性值是否为 Date 对象 - newObj[key] = new Date(obj[key].getTime()).toISOString() // 直接拷贝引用 - } else if (obj[key] && typeof obj[key] === 'object') { - newObj[key] = deepClone(obj[key]) + if (obj[key] instanceof Date) { + newObj[key] = new Date(obj[key].getTime()).toISOString() } else { - newObj[key] = obj[key] + newObj[key] = deepClone(obj[key]) } } } + return newObj + } else { + return obj } - return newObj } - /** * 延时 * @param {*} ms From f60af40459207ecd6f9a93bdb1a7ac3d5ae0334b Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Tue, 1 Aug 2023 14:23:44 +0800 Subject: [PATCH 3/3] =?UTF-8?q?gitbook=20=E5=BD=92=E6=A1=A3=E6=A0=87?= =?UTF-8?q?=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/gitbook/components/BlogArchiveItem.js | 36 +++++++++++ themes/gitbook/index.js | 64 ++++++++++++++++++-- 2 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 themes/gitbook/components/BlogArchiveItem.js diff --git a/themes/gitbook/components/BlogArchiveItem.js b/themes/gitbook/components/BlogArchiveItem.js new file mode 100644 index 00000000..8e9693dc --- /dev/null +++ b/themes/gitbook/components/BlogArchiveItem.js @@ -0,0 +1,36 @@ +import BLOG from '@/blog.config' +import Link from 'next/link' + +/** + * 归档分组 + * @param {*} param0 + * @returns + */ +export default function BlogArchiveItem({ archiveTitle, archivePosts }) { + return ( +
+
+ {archiveTitle} +
+
    + {archivePosts[archiveTitle]?.map(post => ( +
  • +
    + + {post.date?.start_date} + {' '} +   + + + {post.title} + +
    +
  • + ))} +
+
+ ) +} diff --git a/themes/gitbook/index.js b/themes/gitbook/index.js index e5fcaeac..72056e66 100644 --- a/themes/gitbook/index.js +++ b/themes/gitbook/index.js @@ -31,6 +31,9 @@ import { ArticleLock } from './components/ArticleLock' import { Transition } from '@headlessui/react' import { Style } from './style' import CommonHead from '@/components/CommonHead' +import BlogArchiveItem from './components/BlogArchiveItem' +import BlogPostListPage from './components/BlogPostListPage' +import Link from 'next/link' // 主题全局变量 const ThemeGlobalGitbook = createContext() @@ -194,7 +197,9 @@ const LayoutIndex = (props) => { * @returns */ const LayoutPostList = (props) => { - return + return +
+
} /** @@ -253,13 +258,19 @@ const LayoutSearch = (props) => { } /** - * 没有归档 + * 归档页面基本不会用到 * 全靠页面导航 * @param {*} props * @returns */ const LayoutArchive = (props) => { - return + const { archivePosts } = props + + return +
+ {Object.keys(archivePosts)?.map(archiveTitle => )} +
+
} /** @@ -275,14 +286,57 @@ const Layout404 = props => { * 分类列表 */ const LayoutCategoryIndex = (props) => { - return + const { categoryOptions } = props + const { locale } = useGlobal() + return +
+
+ {locale.COMMON.CATEGORY}: +
+
+ {categoryOptions?.map(category => { + return ( + +
+ {category.name}({category.count}) +
+ + ) + })} +
+
+
} /** * 标签列表 */ const LayoutTagIndex = (props) => { - return + const { tagOptions } = props + const { locale } = useGlobal() + + return +
+
+ + {locale.COMMON.TAGS}: +
+
+ {tagOptions?.map(tag => { + return ( +
+ +
+ ) + })} +
+
+
} export {