mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-01 15:10:14 +00:00
feat/theme-switch
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import BLOG from '@/blog.config'
|
||||
import { getPostBlocks } from '@/lib/notion'
|
||||
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { Suspense, useEffect, useState } from 'react'
|
||||
import { idToUuid } from 'notion-utils'
|
||||
import { useRouter } from 'next/router'
|
||||
@@ -9,35 +8,16 @@ import { isBrowser } from '@/lib/utils'
|
||||
import { getNotion } from '@/lib/notion/getNotion'
|
||||
import { getPageTableOfContents } from '@/lib/notion/getPageTableOfContents'
|
||||
import md5 from 'js-md5'
|
||||
import dynamic from 'next/dynamic'
|
||||
import Loading from '@/components/Loading'
|
||||
|
||||
const layout = 'LayoutSlug'
|
||||
|
||||
/**
|
||||
* 懒加载默认主题
|
||||
*/
|
||||
const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/${layout}`), { ssr: true })
|
||||
|
||||
/**
|
||||
* 根据notion的slug访问页面
|
||||
* @param {*} props
|
||||
* @returns
|
||||
*/
|
||||
const Slug = props => {
|
||||
const { theme, setOnLoading } = useGlobal()
|
||||
const { post, siteInfo } = props
|
||||
const { post, siteInfo, Layout } = props
|
||||
const router = useRouter()
|
||||
const [Layout, setLayout] = useState(DefaultLayout)
|
||||
|
||||
// 切换主题
|
||||
useEffect(() => {
|
||||
const loadLayout = async () => {
|
||||
const newLayout = await dynamic(() => import(`@/themes/${theme}/${layout}`))
|
||||
setLayout(newLayout)
|
||||
}
|
||||
loadLayout()
|
||||
}, [theme])
|
||||
|
||||
// 文章锁🔐
|
||||
const [lock, setLock] = useState(post?.password && post?.password !== '')
|
||||
@@ -57,7 +37,6 @@ const Slug = props => {
|
||||
|
||||
// 文章加载
|
||||
useEffect(() => {
|
||||
setOnLoading(false)
|
||||
// 404
|
||||
if (!post) {
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user