From 89b6ad7a06c79fdb4a162a5f2fcf1f28bd789fa4 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Thu, 10 Aug 2023 16:08:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Landing=20=E4=B8=BB=E9=A2=98=E9=87=8D?= =?UTF-8?q?=E5=AE=9A=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/landing/config.js | 3 +++ themes/landing/index.js | 32 +++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/themes/landing/config.js b/themes/landing/config.js index 08487f34..75cd7d01 100644 --- a/themes/landing/config.js +++ b/themes/landing/config.js @@ -57,6 +57,9 @@ const CONFIG = { TESTIMONIALS_SOCIAL_URL: 'https://blog.gaoran.xyz/', TESTIMONIALS_WORD: '“ 感谢大佬的方法。之前尝试过Super、Potion等国外的第三方平台,实现效果一般,个性化程度远不如这个方法,已经用起来了! “', + POST_REDIRECT_ENABLE: process.env.NEXT_PUBLIC_POST_REDIRECT_ENABLE || false, // 是否开启文章地址重定向 ; 用于迁移旧网站域名 + POST_REDIRECT_URL: process.env.NEXT_PUBLIC_POST_REDIRECT_URL || 'https://blog.tangly1024.com', // 重定向网站地址 + NEWSLETTER: process.env.NEXT_PUBLIC_THEME_LANDING_NEWSLETTER || false // 是否开启邮件订阅 请先配置mailchimp功能 https://docs.tangly1024.com/article/notion-next-mailchimp } export default CONFIG diff --git a/themes/landing/index.js b/themes/landing/index.js index f668f8fd..e7661167 100644 --- a/themes/landing/index.js +++ b/themes/landing/index.js @@ -15,6 +15,9 @@ import FeaturesBlocks from './components/FeaturesBlocks' import Testimonials from './components/Testimonials' import Newsletter from './components/Newsletter' import CommonHead from '@/components/CommonHead' +import { useRouter } from 'next/router' +import CONFIG from './config' +import Loading from '@/components/Loading' /** * 这是个配置文件,可以方便在此统一配置信息 @@ -31,8 +34,8 @@ const THEME_CONFIG = { THEME: 'landing' } const LayoutBase = (props) => { const { meta, siteInfo, children } = props - return
- + return
+ {/* 网页SEO */} @@ -72,11 +75,26 @@ const LayoutIndex = (props) => { * @param {*} props * @returns */ -const LayoutSlug = (props) => -
- -
-
+const LayoutSlug = (props) => { + + // 如果 是 /article/[slug] 的文章路径则进行重定向到另一个域名 + const router = useRouter() + if (JSON.parse(CONFIG.POST_REDIRECT_ENABLE) && router.route == '/[prefix]/[slug]') { + const redirectUrl = CONFIG.POST_REDIRECT_URL + router.asPath.replace('?theme=landing', '') + console.log('重定向到博客域名', redirectUrl) + router.push(redirectUrl) + return
+ } + + return + +
+ +
+
+ + +} // 其他布局暂时留空 const LayoutSearch = (props) => From 09e9f883173e64632c445265e5f63ea8d15e0ae0 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Thu, 10 Aug 2023 16:40:13 +0800 Subject: [PATCH 2/2] landing build --- themes/example/index.js | 2 +- themes/landing/index.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/themes/example/index.js b/themes/example/index.js index b32046ff..0e106434 100644 --- a/themes/example/index.js +++ b/themes/example/index.js @@ -129,7 +129,7 @@ const LayoutPostList = props => { slotTop =
{category}
} else if (tag) { slotTop =
#{tag}
- }else if(props.slotTop){ + } else if (props.slotTop) { slotTop = props.slotTop } return ( diff --git a/themes/landing/index.js b/themes/landing/index.js index e7661167..d5a4f194 100644 --- a/themes/landing/index.js +++ b/themes/landing/index.js @@ -1,4 +1,6 @@ +'use client' + /** * 这是一个空白主题,方便您用作创建新主题时的模板,从而开发出您自己喜欢的主题 * 1. 禁用了代码质量检查功能,提高了代码的宽容度;您可以使用标准的html写法 @@ -18,6 +20,7 @@ import CommonHead from '@/components/CommonHead' import { useRouter } from 'next/router' import CONFIG from './config' import Loading from '@/components/Loading' +import { isBrowser } from '@/lib/utils' /** * 这是个配置文件,可以方便在此统一配置信息 @@ -76,12 +79,10 @@ const LayoutIndex = (props) => { * @returns */ const LayoutSlug = (props) => { - // 如果 是 /article/[slug] 的文章路径则进行重定向到另一个域名 const router = useRouter() - if (JSON.parse(CONFIG.POST_REDIRECT_ENABLE) && router.route == '/[prefix]/[slug]') { + if (JSON.parse(CONFIG.POST_REDIRECT_ENABLE) && isBrowser && router.route == '/[prefix]/[slug]') { const redirectUrl = CONFIG.POST_REDIRECT_URL + router.asPath.replace('?theme=landing', '') - console.log('重定向到博客域名', redirectUrl) router.push(redirectUrl) return
}