From e75f45957d199a686306cd649b7227d032ef0eca Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Thu, 19 Oct 2023 11:02:53 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=98=9F=E7=A9=BA?= =?UTF-8?q?=E9=9B=A8=E7=89=B9=E6=95=88BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/StarrySky.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/components/StarrySky.js b/components/StarrySky.js index 5479df93..e0fd3ac4 100644 --- a/components/StarrySky.js +++ b/components/StarrySky.js @@ -1,23 +1,24 @@ /* eslint-disable */ -import React from 'react' +import { useEffect } from 'react' const StarrySky = () => { - React.useEffect(() => { - dark() + useEffect(() => { + renderStarrySky() }, []) return (
- +
) } export default StarrySky + /** * 创建星空雨 * @param config */ -function dark() { +function renderStarrySky() { window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || @@ -124,7 +125,7 @@ function dark() { u() })(), (function t() { - document.getElementsByTagName('html')[0].className == 'dark' && u(), + document.getElementsByTagName('html')[0].className.indexOf('dark')>=0 && u(), window.requestAnimationFrame(t) })() } From d1df05df83ab079bc4832b6595d6a55fa2fcf1cb Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Thu, 19 Oct 2023 11:09:38 +0800 Subject: [PATCH 02/18] nav logo-bar --- themes/nav/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/nav/index.js b/themes/nav/index.js index 29b67fb4..e34c378b 100755 --- a/themes/nav/index.js +++ b/themes/nav/index.js @@ -86,7 +86,7 @@ const LayoutBase = (props) => { {/* 左侧推拉抽屉 */} - + ) } @@ -301,7 +301,7 @@ function getTopPosts({ latestPosts, allNavPages }) { * 英雄区右侧,今日卡牌 * @returns */ -function TodayCard({ cRef }) { +function TodayCard({ cRef, siteInfo }) { const router = useRouter() // 卡牌是否盖住下层 const [isCoverUp, setIsCoverUp] = useState(true) @@ -378,7 +378,7 @@ function TodayCard({ cRef }) { isCoverUp ? '' : ' pointer-events-none' } cursor-pointer today-card-cover absolute w-full h-full top-0`} style={{ - background: `url('${CONFIG.HERO_RECOMMEND_COVER}') no-repeat center /cover` + background: `url('${siteInfo?.pageCover}') no-repeat center /cover` }} > diff --git a/themes/heo/config.js b/themes/heo/config.js index 1d336dc2..a979621c 100644 --- a/themes/heo/config.js +++ b/themes/heo/config.js @@ -25,7 +25,7 @@ const CONFIG = { // 英雄区右侧推荐文章标签, 例如 [推荐] , 最多六篇文章; 若留空白'',则推荐最近更新文章 HERO_RECOMMEND_POST_TAG: '推荐', HERO_RECOMMEND_POST_SORT_BY_UPDATE_TIME: false, // 推荐文章排序,为`true`时将强制按最后修改时间倒序 - HERO_RECOMMEND_COVER: 'https://cdn.pixabay.com/photo/2015/10/30/20/13/sunrise-1014712_1280.jpg', // 英雄区右侧图片 + // HERO_RECOMMEND_COVER: 'https://cdn.pixabay.com/photo/2015/10/30/20/13/sunrise-1014712_1280.jpg', // 英雄区右侧图片 // 右侧个人资料卡牌欢迎语,点击可自动切换 INFOCARD_GREETINGS: [ From 47cfa405ed5375a989a8e4c5b0366b0707a4ea84 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 1 Nov 2023 11:40:06 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E6=8A=98=E5=8F=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=9D=97=E9=BB=98=E8=AE=A4=E5=B1=95=E5=BC=80=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog.config.js | 4 +++- components/PrismMac.js | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/blog.config.js b/blog.config.js index 65683d0d..ae020dac 100644 --- a/blog.config.js +++ b/blog.config.js @@ -114,7 +114,9 @@ const BLOG = { CODE_MAC_BAR: process.env.NEXT_PUBLIC_CODE_MAC_BAR || true, // 代码左上角显示mac的红黄绿图标 CODE_LINE_NUMBERS: process.env.NEXT_PUBLIC_CODE_LINE_NUMBERS || false, // 是否显示行号 - CODE_COLLAPSE: process.env.NEXT_PUBLIC_CODE_COLLAPSE || true, // 是否折叠代码框 + CODE_COLLAPSE: process.env.NEXT_PUBLIC_CODE_COLLAPSE || true, // 是否支持折叠代码框 + CODE_COLLAPSE_EXPAND_DEFAULT: process.env.NEXT_PUBLIC_CODE_COLLAPSE_EXPAND_DEFAULT || true, // 折叠代码默认是展开状态 + // END********代码相关******** // Mermaid 图表CDN diff --git a/components/PrismMac.js b/components/PrismMac.js index 0a69e55e..3e568e9f 100644 --- a/components/PrismMac.js +++ b/components/PrismMac.js @@ -105,13 +105,20 @@ const renderCollapseCode = () => { codeBlock.parentNode.insertBefore(collapseWrapper, codeBlock) panel.appendChild(codeBlock) - header.addEventListener('click', () => { + function collapseCode() { panel.classList.toggle('invisible') panel.classList.toggle('h-0') panel.classList.toggle('h-auto') header.querySelector('svg').classList.toggle('rotate-180') panelWrapper.classList.toggle('border-gray-300') - }) + } + + // 点击后折叠展开代码 + header.addEventListener('click', collapseCode) + // 是否自动展开 + if (JSON.parse(BLOG.CODE_COLLAPSE_EXPAND_DEFAULT)) { + header.click() + } } } From e24b8cfe3ae6d38081e93cf03fd88ae6c3c94bf5 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 1 Nov 2023 14:28:22 +0800 Subject: [PATCH 15/18] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/mapImage.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index f25eda99..0406507f 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -67,13 +67,10 @@ const mapImgUrl = (img, block, type = 'block', from) => { ret = BLOG.NOTION_HOST + '/image/' + encodeURIComponent(ret) + '?table=' + type + '&id=' + block.id } - // UnSplash 随机图片接口优化 - if (ret.includes('source.unsplash.com/random')) { - // 检查原始URL是否已经包含参数 - const separator = ret.includes('?') ? '&' : '?' - // 拼接唯一识别参数,防止请求的图片被缓存 - ret = `${ret}${separator}random=${block.id}` - } + // 随机图片接口优化 防止因url一致而随机结果相同 + const separator = ret.includes('?') ? '&' : '?' + // 拼接唯一识别参数,防止请求的图片被缓存 + ret = `${ret.trim()}${separator}t=${block.id}` // 文章封面 if (from === 'pageCoverThumbnail') { From 960bf97adea1434d891c718ff64cb5a6053e2293 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 1 Nov 2023 22:04:21 +0800 Subject: [PATCH 16/18] v4.0.18 --- .env.local | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.local b/.env.local index 8fb4ae71..48b76dc9 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.17 \ No newline at end of file +NEXT_PUBLIC_VERSION=4.0.18 \ No newline at end of file diff --git a/package.json b/package.json index 586f98cf..6164cbb4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "notion-next", - "version": "4.0.17", + "version": "4.0.18", "homepage": "https://github.com/tangly1024/NotionNext.git", "license": "MIT", "repository": { From 13608c6461d22264b573748e65c84839d907a110 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 1 Nov 2023 23:15:43 +0800 Subject: [PATCH 17/18] =?UTF-8?q?fix=20=E5=9B=BE=E7=89=87emoji?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notion/mapImage.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index 0406507f..8d8c7434 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -67,10 +67,12 @@ const mapImgUrl = (img, block, type = 'block', from) => { ret = BLOG.NOTION_HOST + '/image/' + encodeURIComponent(ret) + '?table=' + type + '&id=' + block.id } - // 随机图片接口优化 防止因url一致而随机结果相同 - const separator = ret.includes('?') ? '&' : '?' - // 拼接唯一识别参数,防止请求的图片被缓存 - ret = `${ret.trim()}${separator}t=${block.id}` + if (!isEmoji(ret)) { + // 随机图片接口优化 防止因url一致而随机结果相同 + const separator = ret.includes('?') ? '&' : '?' + // 拼接唯一识别参数,防止请求的图片被缓存 + ret = `${ret.trim()}${separator}t=${block.id}` + } // 文章封面 if (from === 'pageCoverThumbnail') { @@ -80,4 +82,9 @@ const mapImgUrl = (img, block, type = 'block', from) => { return ret } +function isEmoji(str) { + const emojiRegex = /[\u{1F300}-\u{1F6FF}\u{1F1E0}-\u{1F1FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F900}-\u{1F9FF}\u{1F018}-\u{1F270}]/u; + return emojiRegex.test(str); +} + export { mapImgUrl, compressImage } From 9b6676ad6b17aa48e10cdc7c63bf965da5af71a2 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Mon, 6 Nov 2023 16:39:32 +0800 Subject: [PATCH 18/18] fix/notion-page-cover --- lib/notion/mapImage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index 8d8c7434..b6da8d87 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -67,7 +67,7 @@ const mapImgUrl = (img, block, type = 'block', from) => { ret = BLOG.NOTION_HOST + '/image/' + encodeURIComponent(ret) + '?table=' + type + '&id=' + block.id } - if (!isEmoji(ret)) { + if (!isEmoji(ret) && ret.indexOf('notion.so/images/page-cover') < 0) { // 随机图片接口优化 防止因url一致而随机结果相同 const separator = ret.includes('?') ? '&' : '?' // 拼接唯一识别参数,防止请求的图片被缓存