From c351b76c139955bb26436c2bcd1ddee76a15a1a3 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Thu, 5 Sep 2024 12:13:07 +0800 Subject: [PATCH] =?UTF-8?q?OpenWrite=E9=80=82=E9=85=8D=E6=89=80=E6=9C=89?= =?UTF-8?q?=E4=B8=BB=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/OpenWrite.js | 9 +- themes/example/index.js | 8 +- themes/gitbook/index.js | 6 +- themes/heo/index.js | 9 +- themes/hexo/index.js | 5 +- themes/landing/index.js | 163 +++++---- themes/matery/index.js | 6 +- themes/medium/index.js | 458 +++++++++++++----------- themes/nav/index.js | 6 +- themes/next/components/ArticleDetail.js | 6 +- themes/next/index.js | 404 ++++++++++++--------- themes/nobelium/index.js | 331 +++++++++-------- themes/plog/index.js | 285 ++++++++------- themes/simple/index.js | 10 +- themes/starter/index.js | 4 +- 15 files changed, 953 insertions(+), 757 deletions(-) diff --git a/components/OpenWrite.js b/components/OpenWrite.js index f199e50e..00d001a9 100644 --- a/components/OpenWrite.js +++ b/components/OpenWrite.js @@ -1,7 +1,7 @@ import { siteConfig } from '@/lib/config' import { isBrowser, loadExternalResource } from '@/lib/utils' import { useRouter } from 'next/router' -import { useEffect, useRef } from 'react' +import { useEffect } from 'react' /** * OpenWrite公众号导流插件 * 使用介绍:https://openwrite.cn/guide/readmore/readmore.html#%E4%BA%8C%E3%80%81%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8 @@ -20,8 +20,6 @@ const OpenWrite = () => { '原创不易,完成人机检测,阅读全文' ) - const hasLoaded = useRef(false) - const loadOpenWrite = async () => { try { await loadExternalResource( @@ -48,11 +46,10 @@ const OpenWrite = () => { } useEffect(() => { - if (isBrowser && blogId && !hasLoaded.current) { + if (isBrowser && blogId) { loadOpenWrite() - hasLoaded.current = true } - }, [router]) + }) return <> } diff --git a/themes/example/index.js b/themes/example/index.js index 90580a24..60b896c1 100644 --- a/themes/example/index.js +++ b/themes/example/index.js @@ -179,10 +179,12 @@ const LayoutSlug = props => { {lock ? ( ) : ( -
+
- - +
+ + +
)} diff --git a/themes/gitbook/index.js b/themes/gitbook/index.js index ca82dd52..ceef6df4 100644 --- a/themes/gitbook/index.js +++ b/themes/gitbook/index.js @@ -341,8 +341,10 @@ const LayoutSlug = props => { {/* Notion文章主体 */} {post && ( -
- +
+
+ +
{/* 分享 */} diff --git a/themes/heo/index.js b/themes/heo/index.js index b496ef20..9bab5daf 100644 --- a/themes/heo/index.js +++ b/themes/heo/index.js @@ -288,14 +288,17 @@ const LayoutSlug = props => { return ( <>
+ className={`article h-full w-full ${fullWidth ? '' : 'xl:max-w-5xl'} ${hasCode ? 'xl:w-[73.15vw]' : ''} bg-white dark:bg-[#18171d] dark:border-gray-600 lg:hover:shadow lg:border rounded-2xl lg:px-2 lg:py-4 `}> {/* 文章锁 */} {lock && } {!lock && ( -
+
{/* 文章主体 */} -
+
{/* Notion文章主体 */}
{ {lock && } {!lock && ( -
+
diff --git a/themes/landing/index.js b/themes/landing/index.js index d7301d4c..62d8f9db 100644 --- a/themes/landing/index.js +++ b/themes/landing/index.js @@ -1,4 +1,3 @@ - 'use client' /** @@ -7,21 +6,21 @@ * 2. 内容大部分是在此文件中写死,notion数据从props参数中传进来 * 3. 您可在此网站找到更多喜欢的组件 https://www.tailwind-kit.com/ */ +import Loading from '@/components/Loading' import NotionPage from '@/components/NotionPage' -import Header from './components/Header' -import Footer from './components/Footer' -import Hero from './components/Hero' +import { siteConfig } from '@/lib/config' +import { isBrowser } from '@/lib/utils' +import { useRouter } from 'next/router' +import { useEffect } from 'react' import Features from './components/Features' import FeaturesBlocks from './components/FeaturesBlocks' -import Testimonials from './components/Testimonials' +import Footer from './components/Footer' +import Header from './components/Header' +import Hero from './components/Hero' import Newsletter from './components/Newsletter' -import { useRouter } from 'next/router' -import CONFIG from './config' -import Loading from '@/components/Loading' -import { isBrowser } from '@/lib/utils' -import { siteConfig } from '@/lib/config' import { Pricing } from './components/Pricing' -import { useEffect } from 'react' +import Testimonials from './components/Testimonials' +import CONFIG from './config' /** * 布局框架 @@ -30,22 +29,23 @@ import { useEffect } from 'react' * @param {*} props * @returns */ -const LayoutBase = (props) => { +const LayoutBase = props => { const { children } = props - return
+ return ( +
+ {/* 顶部导航栏 */} +
- {/* 顶部导航栏 */} -
+ {/* 内容 */} +
{children}
- {/* 内容 */} -
- {children} -
- - {/* 底部页脚 */} -
+ {/* 底部页脚 */} +
+ ) } /** @@ -53,16 +53,16 @@ const LayoutBase = (props) => { * @param {*} props * @returns */ -const LayoutIndex = (props) => { +const LayoutIndex = props => { return ( - <> - - - - - - - + <> + + + + + + + ) } @@ -71,7 +71,7 @@ const LayoutIndex = (props) => { * @param {*} props * @returns */ -const LayoutSlug = (props) => { +const LayoutSlug = props => { const { post } = props // 如果 是 /article/[slug] 的文章路径则进行重定向到另一个域名 @@ -79,49 +79,90 @@ const LayoutSlug = (props) => { useEffect(() => { // 404 if (!post) { - setTimeout(() => { - if (isBrowser) { - const article = document.getElementById('notion-article') - if (!article) { - router.push('/404').then(() => { - console.warn('找不到页面', router.asPath) - }) + setTimeout( + () => { + if (isBrowser) { + const article = document.getElementById('notion-article') + if (!article) { + router.push('/404').then(() => { + console.warn('找不到页面', router.asPath) + }) + } } - } - }, siteConfig('POST_WAITING_TIME_FOR_404') * 1000) + }, + siteConfig('POST_WAITING_TIME_FOR_404') * 1000 + ) } }, [post]) - if (JSON.parse(siteConfig('LANDING_POST_REDIRECT_ENABLE', null, CONFIG)) && isBrowser && router.route === '/[prefix]/[slug]') { - const redirectUrl = siteConfig('LANDING_POST_REDIRECT_URL', null, CONFIG) + router.asPath.replace('?theme=landing', '') + if ( + JSON.parse(siteConfig('LANDING_POST_REDIRECT_ENABLE', null, CONFIG)) && + isBrowser && + router.route === '/[prefix]/[slug]' + ) { + const redirectUrl = + siteConfig('LANDING_POST_REDIRECT_URL', null, CONFIG) + + router.asPath.replace('?theme=landing', '') router.push(redirectUrl) - return
+ return ( +
+ +
+ ) } - return <> -
- + return ( + <> +
+
+
+
+ ) } // 其他布局暂时留空 -const LayoutSearch = (props) => <> -const LayoutArchive = (props) => <> -const Layout404 = (props) => <> -const LayoutCategoryIndex = (props) => <> -const LayoutPostList = (props) => <> -const LayoutTagIndex = (props) => <> +const LayoutSearch = props => ( + <> + + +) +const LayoutArchive = props => ( + <> + + +) +const Layout404 = props => ( + <> + + +) +const LayoutCategoryIndex = props => ( + <> + + +) +const LayoutPostList = props => ( + <> + + +) +const LayoutTagIndex = props => ( + <> + + +) export { - CONFIG as THEME_CONFIG, - LayoutBase, - LayoutIndex, - LayoutSearch, - LayoutArchive, - LayoutSlug, Layout404, - LayoutPostList, + LayoutArchive, + LayoutBase, LayoutCategoryIndex, - LayoutTagIndex + LayoutIndex, + LayoutPostList, + LayoutSearch, + LayoutSlug, + LayoutTagIndex, + CONFIG as THEME_CONFIG } diff --git a/themes/matery/index.js b/themes/matery/index.js index 9f642cab..7cbcad19 100644 --- a/themes/matery/index.js +++ b/themes/matery/index.js @@ -254,9 +254,7 @@ const LayoutSlug = props => { {lock && } {!lock && ( -
+
{/* 文章信息 */} {post?.type && post?.type === 'Post' && ( <> @@ -268,7 +266,7 @@ const LayoutSlug = props => { )}
-
+
{/* Notion文章主体 */}
{ const router = useRouter() const [tocVisible, changeTocVisible] = useState(false) const { onLoading, fullWidth } = useGlobal() - const [slotRight, setSlotRight] = useState(null); + const [slotRight, setSlotRight] = useState(null) - useEffect(()=> { + useEffect(() => { if (post?.toc?.length > 0) { setSlotRight(
- ); + ) } else { - setSlotRight(null); + setSlotRight(null) } - },[post]) + }, [post]) const slotTop = return ( - - {/* CSS样式 */} -