From 762fad1da6b728fda9b300d7a3eeb74f0447bab4 Mon Sep 17 00:00:00 2001
From: Vixcity <2091283625@qq.com>
Date: Wed, 1 Feb 2023 12:09:20 +0800
Subject: [PATCH 01/64] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
blog.config.js | 46 +++++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 19 deletions(-)
diff --git a/blog.config.js b/blog.config.js
index c0fcca5e..2bbd9f85 100644
--- a/blog.config.js
+++ b/blog.config.js
@@ -1,25 +1,25 @@
// 注: process.env.XX是Vercel的环境变量,配置方式见:https://docs.tangly1024.com/zh/features/personality
const BLOG = {
// Important page_id!!!Duplicate Template from https://www.notion.so/tanghh/02ab3b8678004aa69e9e415905ef32a5
- NOTION_PAGE_ID: process.env.NOTION_PAGE_ID || '02ab3b8678004aa69e9e415905ef32a5',
+ NOTION_PAGE_ID: process.env.NOTION_PAGE_ID || 'fb7bf0cd0563410e862e5ee67b8a8d33',
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'] @see https://preview.tangly1024.com
THEME_SWITCH: process.env.NEXT_PUBLIC_THEME_SWITCH || false, // 是否显示切换主题按钮
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.
- APPEARANCE: 'light', // ['light', 'dark', 'auto'], // light 日间模式 , dark夜间模式, auto根据时间和主题自动夜间模式
+ SINCE: 2022, // e.g if leave this empty, current year will be used.
+ APPEARANCE: 'auto', // ['light', 'dark', 'auto'], // light 日间模式 , dark夜间模式, auto根据时间和主题自动夜间模式
- AUTHOR: 'tangly1024', // 作者
+ AUTHOR: 'Vixcity', // 作者
BIO: '一个普通的干饭人🍚', // 作者简介
- LINK: 'https://tangly1024.com', // 网站地址
+ LINK: 'https://bolg.vixcitycc.top/', // 网站地址
KEYWORDS: 'Notion, 博客', // 网站关键词 英文逗号隔开
// 社交链接,不需要可留空白,例如 CONTACT_WEIBO:''
- CONTACT_EMAIL: 'mail@tangly1024.com', // 邮箱
+ CONTACT_EMAIL: '2091283625@qq.com', // 邮箱
CONTACT_WEIBO: '', // 你的微博个人主页
CONTACT_TWITTER: '', // 你的twitter个人主页
- CONTACT_GITHUB: 'https://github.com/tangly1024', // 你的github个人主页
- CONTACT_TELEGRAM: 'https://t.me/tangly_1024', // 你的telegram 地址 例如 https://t.me/tangly_1024
+ CONTACT_GITHUB: 'https://github.com/Vixcity', // 你的github个人主页
+ CONTACT_TELEGRAM: '', // 你的telegram 地址 例如 https://t.me/tangly_1024
CONTACT_LINKEDIN: '', // 你的linkedIn 首页
// 网站默认使用PingFangSC及NotoSansSC,
@@ -56,35 +56,43 @@ const BLOG = {
POST_LIST_PREVIEW: process.env.NEXT_PUBLIC_POST_PREVIEW || 'false', // 是否在列表加载文章预览
POST_PREVIEW_LINES: 12, // 预览博客行数
POST_RECOMMEND_COUNT: 6, // 推荐文章数量
- POSTS_PER_PAGE: 12, // post counts per page
- POSTS_SORT_BY: 'notion', // 排序方式 'date'按时间,'notion'由notion控制
+ POSTS_PER_PAGE: 10, // post counts per page
+ POSTS_SORT_BY: 'date', // 排序方式 'date'按时间,'notion'由notion控制
PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量,0为不限制
PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量,0为不限制
// 鼠标点击烟花特效
- FIREWORKS: process.env.NEXT_PUBLIC_FIREWORKS || false, // 开关
+ FIREWORKS: process.env.NEXT_PUBLIC_FIREWORKS || true, // 开关
// 烟花色彩,感谢 https://github.com/Vixcity 提交的色彩
FIREWORKS_COLOR: ['255, 20, 97', '24, 255, 146', '90, 135, 255', '251, 243, 140'],
// 樱花飘落特效
- SAKURA: process.env.NEXT_PUBLIC_SAKURA || false, // 开关
+ SAKURA: process.env.NEXT_PUBLIC_SAKURA || true, // 开关
// 漂浮线段特效
- NEST: process.env.NEXT_PUBLIC_NEST || false, // 开关
+ NEST: process.env.NEXT_PUBLIC_NEST || true, // 开关
// 动态彩带特效
- FLUTTERINGRIBBON: process.env.NEXT_PUBLIC_FLUTTERINGRIBBON || false, // 开关
+ FLUTTERINGRIBBON: process.env.NEXT_PUBLIC_FLUTTERINGRIBBON || true, // 开关
// 静态彩带特效
RIBBON: process.env.NEXT_PUBLIC_RIBBON || false, // 开关
// 星空雨特效 黑夜模式才会生效
- STARRY_SKY: process.env.NEXT_PUBLIC_STARRY_SKY || false, // 开关
+ STARRY_SKY: process.env.NEXT_PUBLIC_STARRY_SKY || true, // 开关
// 悬浮挂件
WIDGET_PET: process.env.NEXT_PUBLIC_WIDGET_PET || true, // 是否显示宠物挂件
- WIDGET_PET_LINK: 'https://cdn.jsdelivr.net/npm/live2d-widget-model-wanko@1.0.5/assets/wanko.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models
- WIDGET_PET_SWITCH_THEME: true, // 点击宠物挂件切换博客主题
+ WIDGET_PET_LINK: 'https://cdn.jsdelivr.net/npm/live2d-widget-model-unitychan@1.0.5/assets/unitychan.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models
+ // 好看的主题
+ // https://cdn.jsdelivr.net/npm/live2d-widget-model-ni-j@1.0.5/assets/ni-j.model.json
+ // https://cdn.jsdelivr.net/npm/live2d-widget-model-nipsilon@1.0.5/assets/nipsilon.model.json
+ // https://cdn.jsdelivr.net/npm/live2d-widget-model-nito@1.0.5/assets/nito.model.json
+ // https://cdn.jsdelivr.net/npm/live2d-widget-model-shizuku@1.0.5/assets/shizuku.model.json
+ // https://cdn.jsdelivr.net/npm/live2d-widget-model-unitychan@1.0.5/assets/unitychan.model.json
+ // https://cdn.jsdelivr.net/npm/live2d-widget-model-koharu@1.0.5/assets/koharu.model.json
+ // https://cdn.jsdelivr.net/npm/live2d-widget-model-haruto@1.0.5/assets/haruto.model.json
+ WIDGET_PET_SWITCH_THEME: false, // 点击宠物挂件切换博客主题
// 音乐播放插件
MUSIC_PLAYER: process.env.NEXT_PUBLIC_MUSIC_PLAYER || false, // 是否使用音乐播放插件
@@ -191,9 +199,9 @@ const BLOG = {
// 作废配置
AVATAR: '/avatar.png', // 作者头像,被notion中的ICON覆盖。若无ICON则取public目录下的avatar.png
- TITLE: process.env.NEXT_PUBLIC_TITLE || 'NotionNext BLOG', // 站点标题 ,被notion中的页面标题覆盖
+ TITLE: process.env.NEXT_PUBLIC_TITLE || 'VIXCITY BLOG', // 站点标题 ,被notion中的页面标题覆盖
HOME_BANNER_IMAGE: './bg_image.jpg', // 首页背景大图, 会被notion中的封面图覆盖,若无封面图则会使用代码中的 /public/bg_image.jpg 文件
- DESCRIPTION: process.env.NEXT_PUBLIC_DESCRIPTION || '这是一个由NotionNext生成的站点', // 站点描述,被notion中的页面描述覆盖
+ DESCRIPTION: process.env.NEXT_PUBLIC_DESCRIPTION || '我的小破博客', // 站点描述,被notion中的页面描述覆盖
// 开发相关
NOTION_ACCESS_TOKEN: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public
From 006bb82170915e25193e2a47c9f915dbf20ab8f4 Mon Sep 17 00:00:00 2001
From: Vixcity <2091283625@qq.com>
Date: Wed, 1 Feb 2023 14:39:40 +0800
Subject: [PATCH 02/64] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20DIY=20=E5=BC=95?=
=?UTF-8?q?=E5=85=A5=20CSS=20=E6=95=B0=E7=BB=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
blog.config.js | 7 +++++--
pages/_document.js | 27 ++++++++++++++++++-------
themes/hexo/LayoutSlug.js | 2 +-
themes/hexo/components/BlogPostCard.js | 2 +-
themes/hexo/components/Card.js | 2 +-
themes/hexo/components/Footer.js | 2 +-
themes/hexo/components/HeaderArticle.js | 4 ++--
themes/hexo/components/SideRight.js | 2 +-
8 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/blog.config.js b/blog.config.js
index c0fcca5e..5f3270bf 100644
--- a/blog.config.js
+++ b/blog.config.js
@@ -71,16 +71,19 @@ const BLOG = {
SAKURA: process.env.NEXT_PUBLIC_SAKURA || false, // 开关
// 漂浮线段特效
- NEST: process.env.NEXT_PUBLIC_NEST || false, // 开关
+ NEST: process.env.NEXT_PUBLIC_NEST || true, // 开关
// 动态彩带特效
- FLUTTERINGRIBBON: process.env.NEXT_PUBLIC_FLUTTERINGRIBBON || false, // 开关
+ FLUTTERINGRIBBON: process.env.NEXT_PUBLIC_FLUTTERINGRIBBON || true, // 开关
// 静态彩带特效
RIBBON: process.env.NEXT_PUBLIC_RIBBON || false, // 开关
// 星空雨特效 黑夜模式才会生效
STARRY_SKY: process.env.NEXT_PUBLIC_STARRY_SKY || false, // 开关
+ // 样式代码
+ CSS_LIST: [''],
+
// 悬浮挂件
WIDGET_PET: process.env.NEXT_PUBLIC_WIDGET_PET || true, // 是否显示宠物挂件
WIDGET_PET_LINK: 'https://cdn.jsdelivr.net/npm/live2d-widget-model-wanko@1.0.5/assets/wanko.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models
diff --git a/pages/_document.js b/pages/_document.js
index 4438697e..d963fc40 100644
--- a/pages/_document.js
+++ b/pages/_document.js
@@ -11,20 +11,33 @@ class MyDocument extends Document {
render() {
return (
-
+
-
-
+
+
+ {console.log(this.renderCSS())}
+ {this.renderCSS()}
-
-
-
-
+
+
+
)
}
+
+ renderCSS() {
+ if (BLOG.CSS_LIST && BLOG.CSS_LIST.length > 0) {
+ return BLOG.CSS_LIST.map((item, index) => {
+ return (
+
+ )
+ })
+ }
+ }
}
export default MyDocument
diff --git a/themes/hexo/LayoutSlug.js b/themes/hexo/LayoutSlug.js
index 327497ac..7ee0c152 100644
--- a/themes/hexo/LayoutSlug.js
+++ b/themes/hexo/LayoutSlug.js
@@ -46,7 +46,7 @@ export const LayoutSlug = props => {
showTag={false}
floatSlot={floatSlot}
>
-
+
{lock &&
}
{!lock &&
diff --git a/themes/hexo/components/BlogPostCard.js b/themes/hexo/components/BlogPostCard.js
index df120154..dcbf6bbd 100644
--- a/themes/hexo/components/BlogPostCard.js
+++ b/themes/hexo/components/BlogPostCard.js
@@ -14,7 +14,7 @@ const BlogPostCard = ({ post, showSummary }) => {
data-aos-easing="ease-in-out"
data-aos-once="false"
data-aos-anchor-placement="top-bottom"
- className="w-full drop-shadow-md border dark:border-black rounded-xl bg-white dark:bg-hexo-black-gray duration-300">
+ className="w-full drop-shadow-md border dark:border-black rounded-xl bg-white dark:bg-hexo-black-gray duration-300 coverArticle">
{
return
<>{headerSlot}>
-
diff --git a/themes/hexo/components/Footer.js b/themes/hexo/components/Footer.js
index 3fc42d36..7cefa951 100644
--- a/themes/hexo/components/Footer.js
+++ b/themes/hexo/components/Footer.js
@@ -14,7 +14,7 @@ const Footer = ({ title }) => {
return (
- );
+ )
}
diff --git a/themes/hexo/components/SideRight.js b/themes/hexo/components/SideRight.js
index 8680f144..5e6da1ec 100644
--- a/themes/hexo/components/SideRight.js
+++ b/themes/hexo/components/SideRight.js
@@ -22,7 +22,7 @@ export default function SideRight(props) {
} = props
return (
-
+
{CONFIG_HEXO.WIDGET_ANALYTICS &&
}
From c0c1d0e1a684968c0b48e5835efa7c29bf31a072 Mon Sep 17 00:00:00 2001
From: Vixcity <2091283625@qq.com>
Date: Wed, 1 Feb 2023 16:04:53 +0800
Subject: [PATCH 03/64] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
blog.config.js | 49 +++++++++++++++++++------------------------------
1 file changed, 19 insertions(+), 30 deletions(-)
diff --git a/blog.config.js b/blog.config.js
index 02866633..2b0c3d28 100644
--- a/blog.config.js
+++ b/blog.config.js
@@ -1,25 +1,25 @@
// 注: process.env.XX是Vercel的环境变量,配置方式见:https://docs.tangly1024.com/zh/features/personality
const BLOG = {
// Important page_id!!!Duplicate Template from https://www.notion.so/tanghh/02ab3b8678004aa69e9e415905ef32a5
- NOTION_PAGE_ID: process.env.NOTION_PAGE_ID || 'fb7bf0cd0563410e862e5ee67b8a8d33',
+ NOTION_PAGE_ID: process.env.NOTION_PAGE_ID || '02ab3b8678004aa69e9e415905ef32a5',
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'] @see https://preview.tangly1024.com
THEME_SWITCH: process.env.NEXT_PUBLIC_THEME_SWITCH || false, // 是否显示切换主题按钮
LANG: 'zh-CN', // e.g 'zh-CN','en-US' see /lib/lang.js for more.
- SINCE: 2022, // e.g if leave this empty, current year will be used.
- APPEARANCE: 'auto', // ['light', 'dark', 'auto'], // light 日间模式 , dark夜间模式, auto根据时间和主题自动夜间模式
+ SINCE: 2021, // e.g if leave this empty, current year will be used.
+ APPEARANCE: 'light', // ['light', 'dark', 'auto'], // light 日间模式 , dark夜间模式, auto根据时间和主题自动夜间模式
- AUTHOR: 'Vixcity', // 作者
+ AUTHOR: 'tangly1024', // 作者
BIO: '一个普通的干饭人🍚', // 作者简介
- LINK: 'https://bolg.vixcitycc.top/', // 网站地址
+ LINK: 'https://tangly1024.com', // 网站地址
KEYWORDS: 'Notion, 博客', // 网站关键词 英文逗号隔开
// 社交链接,不需要可留空白,例如 CONTACT_WEIBO:''
- CONTACT_EMAIL: '2091283625@qq.com', // 邮箱
+ CONTACT_EMAIL: 'mail@tangly1024.com', // 邮箱
CONTACT_WEIBO: '', // 你的微博个人主页
CONTACT_TWITTER: '', // 你的twitter个人主页
- CONTACT_GITHUB: 'https://github.com/Vixcity', // 你的github个人主页
- CONTACT_TELEGRAM: '', // 你的telegram 地址 例如 https://t.me/tangly_1024
+ CONTACT_GITHUB: 'https://github.com/tangly1024', // 你的github个人主页
+ CONTACT_TELEGRAM: 'https://t.me/tangly_1024', // 你的telegram 地址 例如 https://t.me/tangly_1024
CONTACT_LINKEDIN: '', // 你的linkedIn 首页
// 网站默认使用PingFangSC及NotoSansSC,
@@ -60,46 +60,35 @@ const BLOG = {
POST_LIST_PREVIEW: process.env.NEXT_PUBLIC_POST_PREVIEW || 'false', // 是否在列表加载文章预览
POST_PREVIEW_LINES: 12, // 预览博客行数
POST_RECOMMEND_COUNT: 6, // 推荐文章数量
- POSTS_PER_PAGE: 10, // post counts per page
- POSTS_SORT_BY: 'date', // 排序方式 'date'按时间,'notion'由notion控制
+ POSTS_PER_PAGE: 12, // post counts per page
+ POSTS_SORT_BY: 'notion', // 排序方式 'date'按时间,'notion'由notion控制
PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量,0为不限制
PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量,0为不限制
// 鼠标点击烟花特效
- FIREWORKS: process.env.NEXT_PUBLIC_FIREWORKS || true, // 开关
+ FIREWORKS: process.env.NEXT_PUBLIC_FIREWORKS || false, // 开关
// 烟花色彩,感谢 https://github.com/Vixcity 提交的色彩
FIREWORKS_COLOR: ['255, 20, 97', '24, 255, 146', '90, 135, 255', '251, 243, 140'],
// 樱花飘落特效
- SAKURA: process.env.NEXT_PUBLIC_SAKURA || true, // 开关
+ SAKURA: process.env.NEXT_PUBLIC_SAKURA || false, // 开关
// 漂浮线段特效
- NEST: process.env.NEXT_PUBLIC_NEST || true, // 开关
+ NEST: process.env.NEXT_PUBLIC_NEST || false, // 开关
// 动态彩带特效
- FLUTTERINGRIBBON: process.env.NEXT_PUBLIC_FLUTTERINGRIBBON || true, // 开关
+ FLUTTERINGRIBBON: process.env.NEXT_PUBLIC_FLUTTERINGRIBBON || false, // 开关
// 静态彩带特效
RIBBON: process.env.NEXT_PUBLIC_RIBBON || false, // 开关
// 星空雨特效 黑夜模式才会生效
- STARRY_SKY: process.env.NEXT_PUBLIC_STARRY_SKY || true, // 开关
-
- // 样式代码
- CSS_LIST: [''],
+ STARRY_SKY: process.env.NEXT_PUBLIC_STARRY_SKY || false, // 开关
// 悬浮挂件
WIDGET_PET: process.env.NEXT_PUBLIC_WIDGET_PET || true, // 是否显示宠物挂件
- WIDGET_PET_LINK: 'https://cdn.jsdelivr.net/npm/live2d-widget-model-unitychan@1.0.5/assets/unitychan.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models
- // 好看的主题
- // https://cdn.jsdelivr.net/npm/live2d-widget-model-ni-j@1.0.5/assets/ni-j.model.json
- // https://cdn.jsdelivr.net/npm/live2d-widget-model-nipsilon@1.0.5/assets/nipsilon.model.json
- // https://cdn.jsdelivr.net/npm/live2d-widget-model-nito@1.0.5/assets/nito.model.json
- // https://cdn.jsdelivr.net/npm/live2d-widget-model-shizuku@1.0.5/assets/shizuku.model.json
- // https://cdn.jsdelivr.net/npm/live2d-widget-model-unitychan@1.0.5/assets/unitychan.model.json
- // https://cdn.jsdelivr.net/npm/live2d-widget-model-koharu@1.0.5/assets/koharu.model.json
- // https://cdn.jsdelivr.net/npm/live2d-widget-model-haruto@1.0.5/assets/haruto.model.json
- WIDGET_PET_SWITCH_THEME: false, // 点击宠物挂件切换博客主题
+ WIDGET_PET_LINK: 'https://cdn.jsdelivr.net/npm/live2d-widget-model-wanko@1.0.5/assets/wanko.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models
+ WIDGET_PET_SWITCH_THEME: true, // 点击宠物挂件切换博客主题
// 音乐播放插件
MUSIC_PLAYER: process.env.NEXT_PUBLIC_MUSIC_PLAYER || false, // 是否使用音乐播放插件
@@ -206,9 +195,9 @@ const BLOG = {
// 作废配置
AVATAR: '/avatar.png', // 作者头像,被notion中的ICON覆盖。若无ICON则取public目录下的avatar.png
- TITLE: process.env.NEXT_PUBLIC_TITLE || 'VIXCITY BLOG', // 站点标题 ,被notion中的页面标题覆盖
+ TITLE: process.env.NEXT_PUBLIC_TITLE || 'NotionNext BLOG', // 站点标题 ,被notion中的页面标题覆盖
HOME_BANNER_IMAGE: './bg_image.jpg', // 首页背景大图, 会被notion中的封面图覆盖,若无封面图则会使用代码中的 /public/bg_image.jpg 文件
- DESCRIPTION: process.env.NEXT_PUBLIC_DESCRIPTION || '我的小破博客', // 站点描述,被notion中的页面描述覆盖
+ DESCRIPTION: process.env.NEXT_PUBLIC_DESCRIPTION || '这是一个由NotionNext生成的站点', // 站点描述,被notion中的页面描述覆盖
// 开发相关
NOTION_ACCESS_TOKEN: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public
From a64e3d3dce863b32b98d11cc34aff434ede44c2f Mon Sep 17 00:00:00 2001
From: tangly1024
Date: Sun, 19 Mar 2023 19:06:33 +0800
Subject: [PATCH 04/64] =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E8=8F=9C=E5=8D=95?=
=?UTF-8?q?=EF=BC=8C=E9=83=A8=E5=88=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/Collapse.js | 49 +++++---
components/FlutteringRibbon.js | 14 ++-
components/Nest.js | 17 ++-
components/Ribbon.js | 15 ++-
components/Sakura.js | 22 ++--
lib/notion/getNotionData.js | 19 ++--
themes/example/components/DropMenu.js | 38 +++++++
themes/example/components/Nav.js | 33 +++---
themes/example/components/NormalMenuItem.js | 14 +++
themes/hexo/components/Collapse.js | 43 -------
themes/hexo/components/TopNav.js | 2 +-
themes/matery/components/Collapse.js | 75 ------------
themes/next/components/Collapse.js | 38 -------
themes/next/components/CollapseMenu.js | 54 +++++++++
themes/next/components/DropMenu.js | 35 ++++++
themes/next/components/MenuButtonGroup.js | 48 ++++----
themes/next/components/SideAreaLeft.js | 2 +-
themes/next/components/TopNav.js | 119 ++++++++++----------
themes/nobelium/components/DropMenu.js | 38 +++++++
themes/nobelium/components/Nav.js | 25 ++--
themes/simple/LayoutBase.js | 4 +-
themes/simple/components/DropMenu.js | 4 +-
themes/simple/components/NavBarMenu.js | 4 +
23 files changed, 390 insertions(+), 322 deletions(-)
create mode 100644 themes/example/components/DropMenu.js
create mode 100644 themes/example/components/NormalMenuItem.js
delete mode 100644 themes/hexo/components/Collapse.js
delete mode 100644 themes/matery/components/Collapse.js
delete mode 100644 themes/next/components/Collapse.js
create mode 100644 themes/next/components/CollapseMenu.js
create mode 100644 themes/next/components/DropMenu.js
create mode 100644 themes/nobelium/components/DropMenu.js
diff --git a/components/Collapse.js b/components/Collapse.js
index a787bfa2..99629604 100644
--- a/components/Collapse.js
+++ b/components/Collapse.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import React, { useEffect, useImperativeHandle } from 'react'
/**
* 折叠面板组件,支持水平折叠、垂直折叠
@@ -6,12 +6,27 @@ import React from 'react'
* @returns
*/
const Collapse = props => {
- const collapseRef = React.useRef(null)
+ const { collapseRef } = props
+ const ref = React.useRef(null)
const type = props.type || 'vertical'
+
+ useImperativeHandle(collapseRef, () => {
+ return {
+ /**
+ * 当子元素高度变化时,可调用此方法更新折叠组件的高度
+ * @param {*} param0
+ */
+ updateCollapseHeight: ({ height, increase }) => {
+ ref.current.style.height = ref.current.scrollHeight
+ ref.current.style.height = 'auto'
+ }
+ }
+ })
+
/**
- * 折叠
- * @param {*} element
- */
+ * 折叠
+ * @param {*} element
+ */
const collapseSection = element => {
const sectionHeight = element.scrollHeight
const sectionWidth = element.scrollWidth
@@ -34,9 +49,9 @@ const Collapse = props => {
}
/**
- * 展开
- * @param {*} element
- */
+ * 展开
+ * @param {*} element
+ */
const expandSection = element => {
const sectionHeight = element.scrollHeight
const sectionWidth = element.scrollWidth
@@ -58,22 +73,20 @@ const Collapse = props => {
clearTimeout(clearTime)
}
- const updateHeight = () => {
- collapseRef.current.style.height = 'auto'
- }
-
- React.useEffect(() => {
+ useEffect(() => {
if (props.isOpen) {
- expandSection(collapseRef.current)
+ expandSection(ref.current)
} else {
- collapseSection(collapseRef.current)
+ collapseSection(ref.current)
}
+ // 通知父组件高度变化
+ props?.onHeightChange && props.onHeightChange({ height: ref.current.scrollHeight, increase: props.isOpen })
}, [props.isOpen])
return (
-
- {props.children}
-
+
+ {props.children}
+
)
}
Collapse.defaultProps = { isOpen: false }
diff --git a/components/FlutteringRibbon.js b/components/FlutteringRibbon.js
index a615d533..301fbd23 100644
--- a/components/FlutteringRibbon.js
+++ b/components/FlutteringRibbon.js
@@ -1,10 +1,21 @@
/* eslint-disable */
import React from 'react'
-
+const id = 'canvasFlutteringRibbon'
export const FlutteringRibbon = () => {
+ const destroyRibbon = ()=>{
+ const ribbon = document.getElementById(id)
+ if(ribbon && ribbon.parentNode){
+ ribbon.parentNode.removeChild(ribbon)
+ }
+ }
+
React.useEffect(() => {
createFlutteringRibbon()
+ return () => destroyRibbon()
+
}, [])
+ return <>>
+
}
/**
@@ -125,6 +136,7 @@ function createFlutteringRibbon() {
init: function () {
try {
;(this._canvas = document.createElement('canvas')),
+ (this._canvas.id = id),
(this._canvas.style.display = 'block'),
(this._canvas.style.position = 'fixed'),
(this._canvas.style.margin = '0'),
diff --git a/components/Nest.js b/components/Nest.js
index 781cb2bf..74fa85e3 100644
--- a/components/Nest.js
+++ b/components/Nest.js
@@ -1,10 +1,19 @@
/* eslint-disable */
-import React from 'react'
-
+import { useEffect } from 'react'
+const id = 'canvasNestCreated'
export const Nest = () => {
- React.useEffect(() => {
+ const destroyNest = ()=>{
+ const nest = document.getElementById(id)
+ if(nest && nest.parentNode){
+ nest.parentNode.removeChild(nest)
+ }
+ }
+
+ useEffect(() => {
createNest()
+ return () => destroyNest()
}, [])
+ return <>>
}
/**
@@ -65,7 +74,7 @@ function createNest() {
m(o)
}
var i = document.createElement('canvas')
- i.id = 'canvasNestCreated'
+ i.id = id
var a = (function () {
const t = e
return {
diff --git a/components/Ribbon.js b/components/Ribbon.js
index d96e3591..2c6855fc 100644
--- a/components/Ribbon.js
+++ b/components/Ribbon.js
@@ -1,10 +1,20 @@
/* eslint-disable */
-import React from 'react'
+import { useEffect } from 'react'
+const id = 'canvasRibbon'
export const Ribbon = () => {
- React.useEffect(() => {
+ const destroyRibbon = ()=>{
+ const ribbon = document.getElementById(id)
+ if(ribbon && ribbon.parentNode){
+ ribbon.parentNode.removeChild(ribbon)
+ }
+ }
+
+ useEffect(() => {
createRibbon()
+ return () => destroyRibbon()
}, [])
+ return <>>
}
/**
@@ -29,6 +39,7 @@ function createRibbon() {
a = window.innerWidth,
l = window.innerHeight,
d = e.s
+ i.id= id
let r, s
const u = Math
let h = 0
diff --git a/components/Sakura.js b/components/Sakura.js
index 3f69cc25..e814362f 100644
--- a/components/Sakura.js
+++ b/components/Sakura.js
@@ -1,10 +1,19 @@
/* eslint-disable */
-import React from 'react'
-
+import { useEffect } from 'react'
+const id = 'canvas_sakura'
export const Sakura = () => {
- React.useEffect(() => {
+ const destroySakura = ()=>{
+ const sakura = document.getElementById(id)
+ if(sakura && sakura.parentNode){
+ sakura.parentNode.removeChild(sakura)
+ }
+ }
+
+ useEffect(() => {
createSakura({})
+ return () => destroyRibbon()
}, [])
+ return <>>
}
/**
@@ -129,7 +138,7 @@ function createSakura() {
'style',
'position: fixed;left: 0;top: 0;pointer-events: none;'
)
- canvas.setAttribute('id', 'canvas_sakura')
+ canvas.setAttribute('id', id)
document.getElementsByTagName('body')[0].appendChild(canvas)
cxt = canvas.getContext('2d')
var sakuraList = new SakuraList()
@@ -165,15 +174,12 @@ function createSakura() {
stop = requestAnimationFrame(asd)
}
}
- window.onresize = function () {
- var canvasSnow = document.getElementById('canvas_snow')
- }
img.onload = function () {
startSakura()
}
function stopp() {
if (staticx) {
- var child = document.getElementById('canvas_sakura')
+ var child = document.getElementById(id)
child.parentNode.removeChild(child)
window.cancelAnimationFrame(stop)
staticx = false
diff --git a/lib/notion/getNotionData.js b/lib/notion/getNotionData.js
index 44d97f2f..e2fcf242 100644
--- a/lib/notion/getNotionData.js
+++ b/lib/notion/getNotionData.js
@@ -95,8 +95,13 @@ function getCustomNav({ allPages }) {
return customNav
}
-function getCustomMenu({ collectionData }) {
- const menuPages = collectionData.filter(post => (post.type === BLOG.NOTION_PROPERTY_NAME.type_menu || post.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu) && post.status === 'Published')
+/**
+ * 获取自定义菜单
+ * @param {*} allPages
+ * @returns
+ */
+function getCustomMenu({ allPages }) {
+ const menuPages = allPages.filter(post => (post.type === BLOG.NOTION_PROPERTY_NAME.type_menu || post.type === BLOG.NOTION_PROPERTY_NAME.type_sub_menu) && post.status === BLOG.NOTION_PROPERTY_NAME.status_publish)
const menus = []
if (menuPages && menuPages.length > 0) {
menuPages.forEach(e => {
@@ -216,14 +221,12 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
// 文章计数
let postCount = 0
const allPages = collectionData.filter(post => {
- if (post.type === 'Post' && post.status === 'Published') {
+ if (post.type === BLOG.NOTION_PROPERTY_NAME.type_post && post.status === BLOG.NOTION_PROPERTY_NAME.status_publish) {
postCount++
}
return post &&
- post.type &&
- (post.type === 'Post' || post.type === 'Page') &&
- (post.status === 'Published' || post.status === 'Invisible') &&
- (!post.slug.startsWith('http'))
+ (!post?.slug?.startsWith('http')) &&
+ (post?.status === BLOG.NOTION_PROPERTY_NAME.status_publish || post?.status === BLOG.NOTION_PROPERTY_NAME.status_invisible)
})
// Sort by date
@@ -241,7 +244,7 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
const siteInfo = getBlogInfo({ collection, block })
const customNav = getCustomNav({ allPages: collectionData.filter(post => post.type === 'Page' && post.status === 'Published') })
// 新的菜单
- const customMenu = getCustomMenu({ collectionData })
+ const customMenu = await getCustomMenu({ allPages })
const latestPosts = getLatestPosts({ allPages, from, latestPostCount: 5 })
return {
diff --git a/themes/example/components/DropMenu.js b/themes/example/components/DropMenu.js
new file mode 100644
index 00000000..f2c2c802
--- /dev/null
+++ b/themes/example/components/DropMenu.js
@@ -0,0 +1,38 @@
+import Link from 'next/link'
+import { useState } from 'react'
+
+export const DropMenu = ({ link }) => {
+ const [show, changeShow] = useState(false)
+ const hasSubMenu = link?.subMenus?.length > 0
+
+ return changeShow(true)} onMouseOut={() => changeShow(false)} >
+
+ {!hasSubMenu &&
+
+
+ {link?.name}
+ {hasSubMenu && }
+
+
+ }
+
+ {hasSubMenu &&
+
+ {link?.name}
+
+
+ }
+
+ {/* 子菜单 */}
+ {hasSubMenu &&
+ {link.subMenus.map(sLink => {
+ return -
+
+ {sLink.title}
+
+
+ })}
+
}
+
+
+}
diff --git a/themes/example/components/Nav.js b/themes/example/components/Nav.js
index 9e05646b..7fa8cf09 100644
--- a/themes/example/components/Nav.js
+++ b/themes/example/components/Nav.js
@@ -1,6 +1,7 @@
+import BLOG from '@/blog.config'
import { useGlobal } from '@/lib/global'
-import Link from 'next/link'
import CONFIG_EXAMPLE from '../config_example'
+import { DropMenu } from './DropMenu'
/**
* 菜单导航
@@ -8,8 +9,9 @@ import CONFIG_EXAMPLE from '../config_example'
* @returns
*/
export const Nav = (props) => {
- const { customNav } = props
+ const { customNav, customMenu } = props
const { locale } = useGlobal()
+
let links = [
{ icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: CONFIG_EXAMPLE.MENU_SEARCH },
{ icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: CONFIG_EXAMPLE.MENU_ARCHIVE },
@@ -21,23 +23,22 @@ export const Nav = (props) => {
links = links.concat(customNav)
}
+ // 如果 开启自定义菜单,则不再使用 Page生成菜单。
+ if (BLOG.CUSTOM_MENU) {
+ links = customMenu
+ }
+
+ if (!links || links.length === 0) {
+ return null
+ }
+
return (