From 4687c7f08fcab1c9397d2e372fa2fa9904f5416e Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 1 Feb 2023 14:13:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?hexo=20=E5=85=B3=E9=97=AD=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/hexo/components/Header.js | 75 +++++++++++++++++--------------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/themes/hexo/components/Header.js b/themes/hexo/components/Header.js index bf5e5d09..fa2c5e39 100644 --- a/themes/hexo/components/Header.js +++ b/themes/hexo/components/Header.js @@ -15,7 +15,6 @@ const Header = props => { const [typed, changeType] = useState() const { siteInfo } = props useEffect(() => { - scrollTrigger() updateHeaderHeight() if (!typed && window && document.getElementById('typed')) { changeType( @@ -29,45 +28,20 @@ const Header = props => { }) ) } - window.addEventListener('scroll', scrollTrigger) + if (enableAutoScroll) { + scrollTrigger() + window.addEventListener('scroll', scrollTrigger) + } + window.addEventListener('resize', updateHeaderHeight) return () => { - window.removeEventListener('scroll', scrollTrigger) + if (enableAutoScroll) { + window.removeEventListener('scroll', scrollTrigger) + } window.removeEventListener('resize', updateHeaderHeight) } }) - const autoScrollEnd = () => { - if (autoScroll) { - windowTop = window.scrollY - autoScroll = false - } - } - - /** - * 自动吸附滚动,移动端体验不好暂时关闭 - */ - const scrollTrigger = () => { - if (screen.width <= 768) { - return - } - - const scrollS = window.scrollY - // 自动滚动 - if ((scrollS > windowTop) & (scrollS < window.innerHeight) && !autoScroll - ) { - autoScroll = true - window.scrollTo({ top: wrapperTop, behavior: 'smooth' }) - setTimeout(autoScrollEnd, 500) - } - if ((scrollS < windowTop) && (scrollS < window.innerHeight) && !autoScroll) { - autoScroll = true - window.scrollTo({ top: 0, behavior: 'smooth' }) - setTimeout(autoScrollEnd, 500) - } - windowTop = scrollS - } - function updateHeaderHeight () { setTimeout(() => { const wrapperElement = document.getElementById('wrapper') @@ -106,4 +80,37 @@ const Header = props => { ) } +const enableAutoScroll = false // 是否开启自动吸附滚动 + +const autoScrollEnd = () => { + if (autoScroll) { + windowTop = window.scrollY + autoScroll = false + } +} + +/** + * 自动吸附滚动,移动端体验不好暂时关闭 + */ +const scrollTrigger = () => { + if (screen.width <= 768) { + return + } + + const scrollS = window.scrollY + // 自动滚动 + if ((scrollS > windowTop) & (scrollS < window.innerHeight) && !autoScroll + ) { + autoScroll = true + window.scrollTo({ top: wrapperTop, behavior: 'smooth' }) + setTimeout(autoScrollEnd, 500) + } + if ((scrollS < windowTop) && (scrollS < window.innerHeight) && !autoScroll) { + autoScroll = true + window.scrollTo({ top: 0, behavior: 'smooth' }) + setTimeout(autoScrollEnd, 500) + } + windowTop = scrollS +} + export default Header From 1ac2c5598ffc3da06d47711fcc1136a4e9f652d5 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 1 Feb 2023 14:46:28 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=8E=92=E7=89=88=E4=B8=8A=E4=B8=8B=E8=BE=B9=E8=B7=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- styles/notion.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/styles/notion.css b/styles/notion.css index 24f15562..2be54923 100644 --- a/styles/notion.css +++ b/styles/notion.css @@ -700,6 +700,10 @@ svg.notion-page-icon { max-width: 100%; } +.notion-asset-wrapper-image > div { + height: auto !important; +} + .notion-asset-wrapper-full { /* max-width: 100vw; */ } From e542b271f98ec55e89827a8c58ad47cd21b2dd5e Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 1 Feb 2023 15:16:02 +0800 Subject: [PATCH 3/5] Custom External JS/CSS --- blog.config.js | 4 ++++ components/ExternalScript.js | 25 +++++++++++++++++++++++++ pages/_app.js | 2 ++ 3 files changed, 31 insertions(+) create mode 100644 components/ExternalScript.js diff --git a/blog.config.js b/blog.config.js index c0fcca5e..2b0c3d28 100644 --- a/blog.config.js +++ b/blog.config.js @@ -30,6 +30,10 @@ const BLOG = { CUSTOM_FONT_SANS: ['LXGW WenKai'], // 自定义无衬线字体 CUSTOM_FONT_SERIF: ['LXGW WenKai'], // 自定义衬线字体 + // 自定义外部脚本,外部样式 + CUSTOM_EXTERNAL_JS: [''], // e.g. ['http://xx.com/script.js','http://xx.com/script.js'] + CUSTOM_EXTERNAL_CSS: [''], // e.g. ['http://xx.com/style.css','http://xx.com/style.css'] + // 侧栏布局 是否反转(左变右,右变左) 已支持主题: hexo next medium fukasawa example LAYOUT_SIDEBAR_REVERSE: false, diff --git a/components/ExternalScript.js b/components/ExternalScript.js new file mode 100644 index 00000000..b8253726 --- /dev/null +++ b/components/ExternalScript.js @@ -0,0 +1,25 @@ +import BLOG from '@/blog.config' +import { loadExternalResource } from '@/lib/utils' +import React from 'react' + +/** + * 自定义引入外部JS 和 CSS + * @returns + */ +const ExternalScript = () => { + React.useEffect(() => { + if (BLOG.CUSTOM_EXTERNAL_JS && BLOG.CUSTOM_EXTERNAL_JS.length > 0) { + for (const url of BLOG.CUSTOM_EXTERNAL_JS) { + loadExternalResource(url, 'js') + } + } + if (BLOG.CUSTOM_EXTERNAL_CSS && BLOG.CUSTOM_EXTERNAL_CSS.length > 0) { + for (const url of BLOG.CUSTOM_EXTERNAL_CSS) { + loadExternalResource(url, 'css') + } + } + }, []) + return null +} + +export default ExternalScript diff --git a/pages/_app.js b/pages/_app.js index f0eedb2c..eee3dad6 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -31,6 +31,7 @@ import { Ribbon } from '@/components/Ribbon' import { Sakura } from '@/components/Sakura' import { StarrySky } from '@/components/StarrySky' import MusicPlayer from '@/components/MusicPlayer' +import ExternalScript from '@/components/ExternalScript' const Ackee = dynamic(() => import('@/components/Ackee'), { ssr: false }) const Gtag = dynamic(() => import('@/components/Gtag'), { ssr: false }) @@ -59,6 +60,7 @@ const MyApp = ({ Component, pageProps }) => { {JSON.parse(BLOG.NEST) && } {JSON.parse(BLOG.FLUTTERINGRIBBON) && } {JSON.parse(BLOG.RIBBON) && } + // 默认Webfont: 请在font.js文件中检查font-family 新版改从npm本地导入; From 67e3d3b482c2650dfd62ab9e936278d4be6bf690 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 1 Feb 2023 15:16:28 +0800 Subject: [PATCH 4/5] 3.9.0 --- .env.local | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env.local b/.env.local index a8cf9114..03b38e30 100644 --- a/.env.local +++ b/.env.local @@ -1,2 +1,2 @@ # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=3.8.2 +NEXT_PUBLIC_VERSION=3.9.0 diff --git a/package.json b/package.json index 4dca8b5b..611d0921 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "notion-next", - "version": "3.8.2", + "version": "3.9.0", "homepage": "https://github.com/tangly1024/NotionNext.git", "license": "MIT", "repository": { From 78e7ef41c61b46cb011462611e85a20b239599b7 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 1 Feb 2023 15:49:05 +0800 Subject: [PATCH 5/5] favicon --- pages/_document.js | 1 - 1 file changed, 1 deletion(-) diff --git a/pages/_document.js b/pages/_document.js index 4438697e..c24fa5c9 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -14,7 +14,6 @@ class MyDocument extends Document { -