From 76e5d997504254df51bc6c9c251a0f2314ce4221 Mon Sep 17 00:00:00 2001 From: tangly Date: Wed, 23 Nov 2022 18:54:57 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BC=AA=E9=9D=99=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- next.config.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/next.config.js b/next.config.js index 7c8627f1..106e6aea 100644 --- a/next.config.js +++ b/next.config.js @@ -16,6 +16,14 @@ module.exports = withBundleAnalyzer({ 'images.unsplash.com' ] }, + async rewrites() { + return [ + { + source: '/:path*.html', + destination: '/:path*' + } + ] + }, async headers() { return [ { From 189960155c23821c060d21afc387827c396f678b Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Sun, 27 Nov 2022 20:42:45 +0800 Subject: [PATCH 2/8] =?UTF-8?q?medium=20=E4=B8=BB=E9=A2=98=E7=9B=B8?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/medium/components/TopNavBar.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/themes/medium/components/TopNavBar.js b/themes/medium/components/TopNavBar.js index 2fd95649..0dd2ff9f 100644 --- a/themes/medium/components/TopNavBar.js +++ b/themes/medium/components/TopNavBar.js @@ -4,6 +4,9 @@ import LogoBar from './LogoBar' import React from 'react' import Collapse from '@/components/Collapse' import GroupMenu from './GroupMenu' +import { useGlobal } from '@/lib/global' +import CONFIG_MEDIUM from '../config_medium' + /** * 顶部导航栏 + 菜单 * @param {} param0 @@ -14,11 +17,23 @@ export default function TopNavBar(props) { const router = useRouter() const [isOpen, changeShow] = React.useState(false) + const { locale } = useGlobal() + + const defaultLinks = [ + { icon: 'fas fa-th', name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG_MEDIUM.MENU_CATEGORY }, + { icon: 'fas fa-tag', name: locale.COMMON.TAGS, to: '/tag', show: CONFIG_MEDIUM.MENU_TAG }, + { icon: 'fas fa-archive', name: locale.NAV.ARCHIVE, to: '/archive', show: CONFIG_MEDIUM.MENU_ARCHIVE }, + { icon: 'fas fa-search', name: locale.NAV.SEARCH, to: '/search', show: CONFIG_MEDIUM.MENU_SEARCH } + ] + + const navs = defaultLinks.concat(customNav) + const toggleMenuOpen = () => { changeShow(!isOpen) } return
+ {/* 折叠菜单 */}
@@ -26,6 +41,8 @@ export default function TopNavBar(props) {
+ + {/* 图标Logo */} {/* 右侧功能 */} @@ -37,7 +54,7 @@ export default function TopNavBar(props) { {/* 顶部菜单 */}
- {customNav && customNav.map(link => { + {navs && navs.map(link => { if (link.show) { const selected = (router.pathname === link.to) || (router.asPath === link.to) return From 88cecd652b2c9926e62a2e11417252a228224484 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 6 Dec 2022 21:23:38 +0800 Subject: [PATCH 3/8] line-number --- styles/prism-mac-style.css | 4 ---- 1 file changed, 4 deletions(-) diff --git a/styles/prism-mac-style.css b/styles/prism-mac-style.css index da5d7fdf..9f2c5098 100644 --- a/styles/prism-mac-style.css +++ b/styles/prism-mac-style.css @@ -72,8 +72,4 @@ pre[class*='language-'] { pre[class*="language-mermaid"] { background: transparent !important; @apply dark:bg-gray-200 !important; -} - -.line-numbers-rows > span { - height:auto !important; } \ No newline at end of file From a6d3dfe7c0f757f2c1b8086bce98d0a9fce30f4d Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 6 Dec 2022 21:36:12 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E9=80=89=E4=B8=AD=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- styles/notion.css | 4 ++++ styles/prism-mac-style.css | 10 ---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/styles/notion.css b/styles/notion.css index 1e64a28d..b8912a51 100644 --- a/styles/notion.css +++ b/styles/notion.css @@ -1945,4 +1945,8 @@ pre[class*='language-'] { .notion-asset-wrapper-pdf > div { display: block !important; +} + +::selection { + @apply bg-blue-500 text-gray-50 !important; } \ No newline at end of file diff --git a/styles/prism-mac-style.css b/styles/prism-mac-style.css index 9f2c5098..73fbe296 100644 --- a/styles/prism-mac-style.css +++ b/styles/prism-mac-style.css @@ -26,16 +26,6 @@ margin-top: -0.1rem; } -pre[class*='language-'].line-numbers { - position: relative; - padding: 3px; /*修改*/ - padding-left: 3.8em; - counter-reset: linenumber; - max-height: 400px; /*修改*/ - background: black; - border: none; -} - .notion-code > code[class*='language-'], pre[class*='language-'] { background: black; From 23fe756f34986bf2688a4ece28a470121b6b953c Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 6 Dec 2022 22:35:34 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Busuanzi.js | 19 ++++++++----------- components/PrismMac.js | 13 +------------ components/WalineComponent.js | 6 +++++- lib/busuanzi.js | 2 +- 4 files changed, 15 insertions(+), 25 deletions(-) diff --git a/components/Busuanzi.js b/components/Busuanzi.js index 12e592d8..fec41e5f 100644 --- a/components/Busuanzi.js +++ b/components/Busuanzi.js @@ -4,26 +4,23 @@ import { useGlobal } from '@/lib/global' // import { useRouter } from 'next/router' import React from 'react' +let path = '' + export default function Busuanzi () { const { theme } = useGlobal() - const router = useRouter() - - // 切换文章时更新 - React.useEffect(() => { - const busuanziRouteChange = url => { + const Router = useRouter() + Router.events.on('routeChangeComplete', (url, option) => { + if (url !== path) { + path = url busuanzi.fetch() } - router.events.on('routeChangeComplete', busuanziRouteChange) - return () => { - router.events.off('routeChangeComplete', busuanziRouteChange) - } - }, [router.events]) + }) // 更换主题时更新 React.useEffect(() => { if (theme) { busuanzi.fetch() } - }) + }, [theme]) return null } diff --git a/components/PrismMac.js b/components/PrismMac.js index 1aab0ddc..9193cfa6 100644 --- a/components/PrismMac.js +++ b/components/PrismMac.js @@ -9,26 +9,15 @@ import 'prismjs/plugins/line-numbers/prism-line-numbers.css' // mermaid图 import mermaid from 'mermaid' -import { useGlobal } from '@/lib/global' -import { useRouter } from 'next/router' /** * @author https://github.com/txs/ * @returns */ const PrismMac = () => { - const router = useRouter() - const { isDarkMode } = useGlobal() - const scrollTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop - React.useEffect(() => { renderPrismMac() - window.scrollTo(0, scrollTop) - router.events.on('routeChangeComplete', renderPrismMac) - return () => { - router.events.off('routeChangeComplete', renderPrismMac) - } - }, [isDarkMode]) + }) return <> } diff --git a/components/WalineComponent.js b/components/WalineComponent.js index 2bff99f1..a8ccb3ac 100644 --- a/components/WalineComponent.js +++ b/components/WalineComponent.js @@ -3,6 +3,8 @@ import { init } from '@waline/client' import BLOG from '@/blog.config' import { useRouter } from 'next/router' +const path = '' + /** * @see https://waline.js.org/guide/get-started.html * @param {*} props @@ -14,7 +16,9 @@ const WalineComponent = (props) => { const router = useRouter() const updateWaline = url => { - walineInstanceRef.current?.update(props) + if (url !== path) { + walineInstanceRef.current?.update(props) + } } React.useEffect(() => { diff --git a/lib/busuanzi.js b/lib/busuanzi.js index df0564c4..9255485a 100644 --- a/lib/busuanzi.js +++ b/lib/busuanzi.js @@ -55,7 +55,7 @@ bszCaller = { const fetch = () => { bszTag && bszTag.hides() bszCaller.fetch('//busuanzi.ibruce.info/busuanzi?jsonpCallback=BusuanziCallback', function (t) { - // console.log('不蒜子请求结果',t) + // console.log('不蒜子',t) bszTag.texts(t), bszTag.shows() }) } From 742e783c916d8a6d6da74389a9c9c414fae5e222 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Tue, 6 Dec 2022 22:41:59 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=87=8F=E5=B0=91=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/WalineComponent.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/components/WalineComponent.js b/components/WalineComponent.js index a8ccb3ac..a47999c7 100644 --- a/components/WalineComponent.js +++ b/components/WalineComponent.js @@ -4,31 +4,33 @@ import BLOG from '@/blog.config' import { useRouter } from 'next/router' const path = '' - +let waline = null /** * @see https://waline.js.org/guide/get-started.html * @param {*} props * @returns */ const WalineComponent = (props) => { - const walineInstanceRef = React.useRef(null) const containerRef = React.createRef() const router = useRouter() const updateWaline = url => { if (url !== path) { - walineInstanceRef.current?.update(props) + waline.update(props) } } React.useEffect(() => { - walineInstanceRef.current = init({ - ...props, - el: containerRef.current, - serverURL: BLOG.COMMENT_WALINE_SERVER_URL - }) - router.events.on('routeChangeComplete', updateWaline) + if (!waline) { + waline = init({ + ...props, + el: containerRef.current, + serverURL: BLOG.COMMENT_WALINE_SERVER_URL + }) + } + // 跳转评论 + router.events.on('routeChangeComplete', updateWaline) const anchor = window.location.hash if (anchor) { // 选择需要观察变动的节点 @@ -58,7 +60,8 @@ const WalineComponent = (props) => { } return () => { - walineInstanceRef.current?.destroy() + waline.destroy() + waline = null router.events.off('routeChangeComplete', updateWaline) } }, []) From cb86beec208fc031d2176b874330426d7fd64df4 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 7 Dec 2022 12:22:22 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9loading=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/[...slug].js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pages/[...slug].js b/pages/[...slug].js index 63eb5e51..997297e7 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -24,6 +24,7 @@ const Slug = props => { const [lock, setLock] = React.useState(post?.password && post?.password !== '') React.useEffect(() => { + changeLoadingState(false) if (post?.password && post?.password !== '') { setLock(true) } else { @@ -32,7 +33,6 @@ const Slug = props => { }, [post]) if (!post) { - changeLoadingState(true) setTimeout(() => { if (isBrowser()) { const article = document.getElementById('container') @@ -47,8 +47,6 @@ const Slug = props => { return } - changeLoadingState(false) - /** * 验证文章密码 * @param {*} result From ac65dbc95c1065c0ebe6765a56846eab792aef91 Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Wed, 7 Dec 2022 12:34:19 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=8A=98=E5=8F=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A1=86=E5=AE=BD=E5=BA=A6?= 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 b8912a51..e4b66a35 100644 --- a/styles/notion.css +++ b/styles/notion.css @@ -929,7 +929,7 @@ svg.notion-page-icon { .notion-toggle { padding: 3px 2px; - max-width: 100%; + width: 100%; } .notion-toggle > summary { cursor: pointer;