动态组件模式调整

This commit is contained in:
tangly1024.com
2024-11-18 18:10:18 +08:00
parent ab2129464f
commit 21d9bc03f7
22 changed files with 294 additions and 121 deletions

View File

@@ -3,17 +3,16 @@ import { siteConfig } from '@/lib/config'
import { getGlobalData } from '@/lib/db/getSiteData'
import { isBrowser } from '@/lib/utils'
import { formatDateFmt } from '@/lib/utils/formatDate'
import { getLayoutByTheme } from '@/themes/theme'
import { DynamicLayout } from '@/themes/theme'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
/**
* 归档首页
* @param {*} props
* @returns
*/
const ArchiveIndex = props => {
// 根据页面路径加载不同Layout文件
const Layout = getLayoutByTheme({
theme: siteConfig('THEME'),
router: useRouter()
})
useEffect(() => {
if (isBrowser) {
const anchor = window.location.hash
@@ -28,7 +27,9 @@ const ArchiveIndex = props => {
}
}, [])
return <Layout {...props} />
const router = useRouter()
const theme = siteConfig('THEME', BLOG.THEME, props.NOTION_CONFIG)
return <DynamicLayout theme={theme} router={router} {...props} />
}
export async function getStaticProps({ locale }) {