mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-02 15:10:16 +00:00
gitbook首页跳转
This commit is contained in:
@@ -1,10 +1,33 @@
|
||||
import { useRouter } from 'next/router'
|
||||
import LayoutBase from './LayoutBase'
|
||||
import Announcement from './components/Announcement'
|
||||
|
||||
import { useEffect } from 'react'
|
||||
import CONFIG_GITBOOK from './config_gitbook'
|
||||
import { isBrowser } from '@/lib/utils'
|
||||
/**
|
||||
* gitbook的首页
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
export const LayoutIndex = (props) => {
|
||||
const router = useRouter()
|
||||
// 直接显示指定页面
|
||||
useEffect(() => {
|
||||
router.push(CONFIG_GITBOOK.INDEX_PAGE).then(() => {
|
||||
console.log('跳转到指定首页', CONFIG_GITBOOK.INDEX_PAGE)
|
||||
setTimeout(() => {
|
||||
if (isBrowser()) {
|
||||
const article = document.getElementById('notion-article')
|
||||
if (!article) {
|
||||
console.log('请检查您的Notion数据库中是否包含此slug页面: ', CONFIG_GITBOOK.INDEX_PAGE)
|
||||
const containerInner = document.getElementById('container-inner')
|
||||
const newHTML = `<h1 class="text-3xl pt-12 dark:text-gray-300">配置有误</h1><blockquote class="notion-quote notion-block-ce76391f3f2842d386468ff1eb705b92"><div>请在您的notion中添加一个slug为${CONFIG_GITBOOK.INDEX_PAGE}的文章</div></blockquote>`
|
||||
containerInner.insertAdjacentHTML('afterbegin', newHTML)
|
||||
}
|
||||
}
|
||||
}, 7 * 1000)
|
||||
})
|
||||
}, [])
|
||||
return <LayoutBase {...props}>
|
||||
{/* gitbook主题首页只显示公告 */}
|
||||
<Announcement {...props}/>
|
||||
</LayoutBase>
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user