Merge pull request #1914 from tangly1024/fix/little-change

redirect
This commit is contained in:
tangly1024
2024-02-24 15:23:15 +08:00
committed by GitHub
2 changed files with 5 additions and 3 deletions

View File

@@ -297,6 +297,8 @@ const CONFIG = {
STARTER_404_TEXT: '抱歉!您要查找的页面不存在。可能已经移动或删除。',
STARTER_404_BACK: '回到主页',
STARTER_POST_REDIRECT_ENABLE: true, // 默認開啟重定向
STARTER_POST_REDIRECT_URL: 'https://blog.tangly1024.com', // 重定向域名
STARTER_NEWSLETTER: process.env.NEXT_PUBLIC_THEME_STARTER_NEWSLETTER || false // 是否开启邮件订阅 请先配置mailchimp功能 https://docs.tangly1024.com/article/notion-next-mailchimp
}
export default CONFIG

View File

@@ -112,10 +112,10 @@ const LayoutIndex = (props) => {
const LayoutSlug = (props) => {
// 如果 是 /article/[slug] 的文章路径则进行重定向到另一个域名
const router = useRouter()
if (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 (siteConfig('STARTER_POST_REDIRECT_ENABLE', null, CONFIG) && isBrowser && router.route === '/[prefix]/[slug]') {
const redirectUrl = siteConfig('STARTER_POST_REDIRECT_URL', null, CONFIG) + router.asPath.replace('?theme=landing', '')
router.push(redirectUrl)
return <div id='theme-landing'><Loading /></div>
return <div id='theme-starter'><Loading /></div>
}
const { post } = props