From 00d32c81e08ad8f1d74ea661fb8b50b1f945447c Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 7 Jun 2023 15:39:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BC=98=E5=8C=96=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E5=BC=82=E6=AD=A5=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Live2D.js | 7 +-- components/Loading.js | 23 ++++----- components/LoadingCover.js | 10 ++-- lib/global.js | 2 + pages/404.js | 3 +- pages/[...slug].js | 61 ++++++++++++++---------- pages/archive/index.js | 26 ++++++++-- pages/category/[category]/index.js | 33 +++++++++---- pages/category/[category]/page/[page].js | 31 ++++++++---- pages/category/index.js | 26 ++++++++-- pages/index.js | 32 ++++--------- pages/page/[page].js | 31 +++++++++--- pages/search/[keyword]/index.js | 25 ++++++++-- pages/search/[keyword]/page/[page].js | 25 ++++++++-- pages/search/index.js | 23 +++++++-- pages/tag/[tag]/index.js | 27 ++++++++--- pages/tag/[tag]/page/[page].js | 28 +++++++---- pages/tag/index.js | 24 ++++++++-- themes/example/Layout404.js | 2 + themes/example/LayoutArchive.js | 2 + themes/example/LayoutCategory.js | 2 + themes/example/LayoutCategoryIndex.js | 2 + themes/example/LayoutIndex.js | 2 + themes/example/LayoutPage.js | 2 + themes/example/LayoutSlug.js | 2 + themes/example/LayoutTag.js | 2 + themes/example/LayoutTagIndex.js | 2 + themes/example/index.js | 25 ---------- themes/fukasawa/Layout404.js | 2 + themes/fukasawa/LayoutArchive.js | 2 + themes/fukasawa/LayoutCategory.js | 2 + themes/fukasawa/LayoutCategoryIndex.js | 2 + themes/fukasawa/LayoutIndex.js | 2 + themes/fukasawa/LayoutPage.js | 2 + themes/fukasawa/LayoutSearch.js | 2 + themes/fukasawa/LayoutSlug.js | 2 + themes/fukasawa/LayoutTag.js | 3 +- themes/fukasawa/LayoutTagIndex.js | 3 +- themes/fukasawa/index.js | 25 ---------- themes/hexo/Layout404.js | 1 + themes/hexo/LayoutArchive.js | 2 + themes/hexo/LayoutCategory.js | 2 + themes/hexo/LayoutCategoryIndex.js | 2 + themes/hexo/LayoutIndex.js | 2 + themes/hexo/LayoutPage.js | 2 + themes/hexo/LayoutSearch.js | 2 + themes/hexo/LayoutSlug.js | 2 + themes/hexo/LayoutTag.js | 2 + themes/hexo/LayoutTagIndex.js | 2 + themes/hexo/index.js | 25 ---------- themes/matery/Layout404.js | 2 + themes/matery/LayoutArchive.js | 2 + themes/matery/LayoutCategory.js | 2 + themes/matery/LayoutCategoryIndex.js | 2 + themes/matery/LayoutIndex.js | 2 + themes/matery/LayoutPage.js | 2 + themes/matery/LayoutSearch.js | 2 + themes/matery/LayoutSlug.js | 2 + themes/matery/LayoutTag.js | 3 +- themes/matery/LayoutTagIndex.js | 3 +- themes/matery/index.js | 25 ---------- themes/medium/Layout404.js | 2 + themes/medium/LayoutArchive.js | 2 + themes/medium/LayoutCategory.js | 2 + themes/medium/LayoutCategoryIndex.js | 1 + themes/medium/LayoutIndex.js | 2 + themes/medium/LayoutPage.js | 2 + themes/medium/LayoutSearch.js | 2 + themes/medium/LayoutSlug.js | 2 + themes/medium/LayoutTag.js | 2 + themes/medium/LayoutTagIndex.js | 2 + themes/medium/index.js | 25 ---------- themes/next/Layout404.js | 1 + themes/next/LayoutArchive.js | 2 + themes/next/LayoutCategory.js | 2 + themes/next/LayoutCategoryIndex.js | 2 + themes/next/LayoutIndex.js | 5 +- themes/next/LayoutPage.js | 2 + themes/next/LayoutSearch.js | 2 + themes/next/LayoutSlug.js | 2 + themes/next/LayoutTag.js | 2 + themes/next/LayoutTagIndex.js | 2 + themes/next/components/ArticleDetail.js | 3 +- themes/next/config_next.js | 3 +- themes/next/index.js | 25 ---------- themes/nobelium/Layout404.js | 2 + themes/nobelium/LayoutArchive.js | 2 + themes/nobelium/LayoutCategory.js | 2 + themes/nobelium/LayoutCategoryIndex.js | 2 + themes/nobelium/LayoutIndex.js | 2 + themes/nobelium/LayoutPage.js | 2 + themes/nobelium/LayoutSearch.js | 2 + themes/nobelium/LayoutSlug.js | 2 + themes/nobelium/LayoutTag.js | 2 + themes/nobelium/LayoutTagIndex.js | 2 + themes/nobelium/index.js | 25 ---------- themes/simple/Layout404.js | 2 + themes/simple/LayoutArchive.js | 2 + themes/simple/LayoutCategory.js | 2 + themes/simple/LayoutCategoryIndex.js | 2 + themes/simple/LayoutIndex.js | 2 + themes/simple/LayoutPage.js | 2 + themes/simple/LayoutSearch.js | 2 + themes/simple/LayoutSlug.js | 2 + themes/simple/LayoutTag.js | 2 + themes/simple/LayoutTagIndex.js | 2 + themes/simple/index.js | 25 ---------- 107 files changed, 467 insertions(+), 338 deletions(-) delete mode 100644 themes/example/index.js delete mode 100644 themes/fukasawa/index.js delete mode 100644 themes/hexo/index.js delete mode 100644 themes/matery/index.js delete mode 100644 themes/medium/index.js delete mode 100644 themes/next/index.js delete mode 100644 themes/nobelium/index.js delete mode 100644 themes/simple/index.js diff --git a/components/Live2D.js b/components/Live2D.js index f75c5438..2fc6327f 100644 --- a/components/Live2D.js +++ b/components/Live2D.js @@ -6,9 +6,10 @@ import { useEffect } from 'react' export default function Live2D() { const { theme, switchTheme } = useGlobal() + const showPet = JSON.parse(BLOG.WIDGET_PET) useEffect(() => { - if (BLOG.WIDGET_PET) { + if (showPet) { Promise.all([ loadExternalResource('https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/live2d.min.js', 'js') ]).then((e) => { @@ -17,7 +18,7 @@ export default function Live2D() { try { loadlive2d('live2d', BLOG.WIDGET_PET_LINK) } catch (error) { - + console.error('读取PET模型', error) } } }) @@ -30,7 +31,7 @@ export default function Live2D() { } } - if (!BLOG.WIDGET_PET || !JSON.parse(BLOG.WIDGET_PET)) { + if (!showPet) { return <> } diff --git a/components/Loading.js b/components/Loading.js index e7c5f5a1..1cf295cd 100644 --- a/components/Loading.js +++ b/components/Loading.js @@ -1,21 +1,22 @@ -import { useGlobal } from '@/lib/global' -import { useEffect } from 'react' /** * 主题文件被加载出之前的占位符 * @returns */ const Loading = (props) => { - const { theme, setOnReading } = useGlobal() +// const { theme, setOnReading } = useGlobal() + // console.log('开启遮罩') + // setOnReading(true) - useEffect(() => { - // 返回一个函数,在组件销毁时设置 onReading 为 false - return () => { - setTimeout(() => { - setOnReading(false) - }, 500) - } - }, [theme]) + // useEffect(() => { + // // 返回一个函数,在组件销毁时设置 onReading 为 false + // return () => { + // setTimeout(() => { + // console.log('关闭遮罩') + // setOnReading(false) + // }, 500) + // } + // }) return
diff --git a/components/LoadingCover.js b/components/LoadingCover.js index 148425e7..c9ec6752 100644 --- a/components/LoadingCover.js +++ b/components/LoadingCover.js @@ -1,15 +1,13 @@ /** - * 加载主题文件时的全局遮罩 + * 加载文件时的全局遮罩 * @returns */ const LoadingCover = (props) => { const { onReading } = props - return <> -
-

-
- + return
+ +
} export default LoadingCover diff --git a/lib/global.js b/lib/global.js index db8b3349..f96d326a 100644 --- a/lib/global.js +++ b/lib/global.js @@ -33,6 +33,8 @@ export function GlobalContextProvider({ children }) { const handleBeforeUnload = (event) => { setOnReading(true) } + // 监听页面元素加载完 + setOnReading(false) window.addEventListener('beforeunload', handleBeforeUnload) return () => { window.removeEventListener('beforeunload', handleBeforeUnload) diff --git a/pages/404.js b/pages/404.js index 3afa60ee..f23edcec 100644 --- a/pages/404.js +++ b/pages/404.js @@ -1,7 +1,6 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' import { useGlobal } from '@/lib/global' import dynamic from 'next/dynamic' -import Loading from '@/components/Loading' /** * 404 @@ -11,7 +10,7 @@ import Loading from '@/components/Loading' const NoFound = props => { const { theme, siteInfo } = useGlobal() const meta = { title: `${props?.siteInfo?.title} | 页面找不到啦`, image: siteInfo?.pageCover } - const Layout404 = dynamic(() => import(`@/themes/${theme}/Layout404`).then(async (m) => { return m.Layout404 }), { ssr: true, loading: () => }) + const Layout404 = dynamic(() => import(`@/themes/${theme}/Layout404`)) return } diff --git a/pages/[...slug].js b/pages/[...slug].js index 138a9cda..f0d3f8d2 100644 --- a/pages/[...slug].js +++ b/pages/[...slug].js @@ -2,7 +2,7 @@ import BLOG from '@/blog.config' import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' import { useGlobal } from '@/lib/global' -import { useEffect, useState } from 'react' +import { Suspense, useEffect, useState } from 'react' import { idToUuid } from 'notion-utils' import { useRouter } from 'next/router' import { isBrowser } from '@/lib/utils' @@ -12,6 +12,11 @@ import md5 from 'js-md5' import dynamic from 'next/dynamic' import Loading from '@/components/Loading' +/** + * 懒加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutSlug`), { ssr: true }) + /** * 根据notion的slug访问页面 * @param {*} props @@ -21,10 +26,18 @@ const Slug = props => { const { theme, setOnLoading } = useGlobal() const { post, siteInfo } = props const router = useRouter() + const [Layout, setLayout] = useState(DefaultLayout) + + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutSlug`))) + } + loadLayout() + }, [theme]) // 文章锁🔐 const [lock, setLock] = useState(post?.password && post?.password !== '') - const LayoutSlug = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutSlug }), { ssr: true, loading: () => }) /** * 验证文章密码 @@ -39,9 +52,24 @@ const Slug = props => { return false } + // 文章加载 useEffect(() => { setOnLoading(false) + // 404 + if (!post) { + setTimeout(() => { + if (isBrowser()) { + const article = document.getElementById('notion-article') + if (!article) { + router.push('/404').then(() => { + console.warn('找不到页面', router.asPath) + }) + } + } + }, 8 * 1000) // 404时长 8秒 + } + // 文章加密 if (post?.password && post?.password !== '') { setLock(true) } else { @@ -56,37 +84,20 @@ const Slug = props => { }) }, [post]) - if (!post) { - setTimeout(() => { - if (isBrowser()) { - const article = document.getElementById('notion-article') - if (!article) { - router.push('/404').then(() => { - console.warn('找不到页面', router.asPath) - }) - } - } - }, 8 * 1000) // 404时长 8秒 - const meta = { title: `${props?.siteInfo?.title || BLOG.TITLE} | loading`, image: siteInfo?.pageCover || BLOG.HOME_BANNER_IMAGE } - - return - } - - props = { ...props, lock, setLock, validPassword } - const meta = { - title: `${post?.title} | ${siteInfo?.title}`, + title: post ? `${post?.title} | ${siteInfo?.title}` : `${props?.siteInfo?.title || BLOG.TITLE} | loading`, description: post?.summary, type: post?.type, slug: post?.slug, - image: post?.page_cover, + image: post?.page_cover || (siteInfo?.pageCover || BLOG.HOME_BANNER_IMAGE), category: post?.category?.[0], tags: post?.tags } + props = { ...props, lock, meta, setLock, validPassword } - return ( - - ) + return }> + + } export async function getStaticPaths() { diff --git a/pages/archive/index.js b/pages/archive/index.js index 6a247414..bb095411 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -1,13 +1,28 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import React from 'react' +import React, { Suspense, useEffect, useState } from 'react' import { useGlobal } from '@/lib/global' import dynamic from 'next/dynamic' import BLOG from '@/blog.config' + import Loading from '@/components/Loading' +/** + * 加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutArchive`), { ssr: true }) + const ArchiveIndex = props => { - const { theme, locale } = useGlobal() const { siteInfo } = props + const { theme, locale } = useGlobal() + const [Layout, setLayout] = useState(DefaultLayout) + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutArchive`))) + } + loadLayout() + }, [theme]) + const meta = { title: `${locale.NAV.ARCHIVE} | ${siteInfo?.title}`, description: siteInfo?.description, @@ -16,8 +31,11 @@ const ArchiveIndex = props => { type: 'website' } - const LayoutArchive = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutArchive }), { ssr: true, loading: () => }) - return + props = { ...props, meta } + + return }> + + } export async function getStaticProps() { diff --git a/pages/category/[category]/index.js b/pages/category/[category]/index.js index 28725614..1db1e85c 100644 --- a/pages/category/[category]/index.js +++ b/pages/category/[category]/index.js @@ -1,23 +1,33 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import React from 'react' +import React, { Suspense, useEffect, useState } from 'react' import { useGlobal } from '@/lib/global' import dynamic from 'next/dynamic' import BLOG from '@/blog.config' + import Loading from '@/components/Loading' +/** + * 加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutCategory`), { ssr: true }) + /** * 分类页 * @param {*} props * @returns */ export default function Category(props) { - const { theme } = useGlobal() - const { siteInfo, posts } = props - const { locale } = useGlobal() - if (!posts) { - const Layout404 = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.Layout404 }), { ssr: true, loading: () => }) - return - } + const { siteInfo } = props + const { locale, theme } = useGlobal() + const [Layout, setLayout] = useState(DefaultLayout) + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutCategory`))) + } + loadLayout() + }, [theme]) + const meta = { title: `${props.category} | ${locale.COMMON.CATEGORY} | ${ siteInfo?.title || '' @@ -28,8 +38,11 @@ export default function Category(props) { type: 'website' } - const LayoutCategory = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutCategory }), { ssr: true, loading: () => }) - return + props = { ...props, meta } + + return }> + + } export async function getStaticProps({ params: { category } }) { diff --git a/pages/category/[category]/page/[page].js b/pages/category/[category]/page/[page].js index bb7d6d26..7ed2d109 100644 --- a/pages/category/[category]/page/[page].js +++ b/pages/category/[category]/page/[page].js @@ -1,10 +1,16 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import React from 'react' +import React, { Suspense, useEffect, useState } from 'react' import { useGlobal } from '@/lib/global' import dynamic from 'next/dynamic' import BLOG from '@/blog.config' + import Loading from '@/components/Loading' +/** + * 加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutCategory`), { ssr: true }) + /** * 分类页 * @param {*} props @@ -12,12 +18,18 @@ import Loading from '@/components/Loading' */ export default function Category(props) { const { theme } = useGlobal() - const { siteInfo, posts } = props + const { siteInfo } = props const { locale } = useGlobal() - if (!posts) { - const Layout404 = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.Layout404 }), { ssr: true, loading: () => }) - return - } + + const [Layout, setLayout] = useState(DefaultLayout) + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutCategory`))) + } + loadLayout() + }, [theme]) + const meta = { title: `${props.category} | ${locale.COMMON.CATEGORY} | ${ siteInfo?.title || '' @@ -28,8 +40,11 @@ export default function Category(props) { type: 'website' } - const LayoutCategory = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutCategory }), { ssr: true, loading: () => }) - return + props = { ...props, meta } + + return }> + + } export async function getStaticProps({ params: { category, page } }) { diff --git a/pages/category/index.js b/pages/category/index.js index 8c7c6515..d4c6ab00 100644 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -1,9 +1,16 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import React from 'react' +import React, { Suspense, useEffect, useState } from 'react' import { useGlobal } from '@/lib/global' import dynamic from 'next/dynamic' import BLOG from '@/blog.config' +import Loading from '@/components/Loading' + +/** + * 加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutCategoryIndex`), { ssr: true }) + /** * 分类首页 * @param {*} props @@ -13,6 +20,16 @@ export default function Category(props) { const { theme } = useGlobal() const { locale } = useGlobal() const { siteInfo } = props + const [Layout, setLayout] = useState(DefaultLayout) + + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutCategoryIndex`))) + } + loadLayout() + }, [theme]) + const meta = { title: `${locale.COMMON.CATEGORY} | ${siteInfo?.title}`, description: siteInfo?.description, @@ -20,8 +37,11 @@ export default function Category(props) { slug: 'category', type: 'website' } - const LayoutCategoryIndex = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutCategoryIndex }), { ssr: false }) - return + props = { ...props, meta } + + return }> + + } export async function getStaticProps() { diff --git a/pages/index.js b/pages/index.js index 94334aef..8de156c9 100644 --- a/pages/index.js +++ b/pages/index.js @@ -11,9 +11,7 @@ import Loading from '@/components/Loading' /** * 懒加载默认主题 */ -const DefaultLayoutIndex = dynamic(() => import(`@/themes/${BLOG.THEME}`).then(async (m) => { - return m.LayoutIndex -}), { ssr: true }) +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutIndex`), { ssr: true }) /** * 首页布局 @@ -22,31 +20,19 @@ const DefaultLayoutIndex = dynamic(() => import(`@/themes/${BLOG.THEME}`).then(a */ const Index = props => { // 动态切换主题 - const { theme, setOnReading } = useGlobal() - const [LayoutIndex, setLayoutIndex] = useState(DefaultLayoutIndex) - + const { theme } = useGlobal() + const [Layout, setLayoutIndex] = useState(DefaultLayout) useEffect(() => { const loadLayout = async () => { - try { - const NewLayoutIndex = await dynamic(() => import(`@/themes/${theme}`).then(async (m) => { - setOnReading(false) - return m.LayoutIndex - })) - - setLayoutIndex(NewLayoutIndex) - } catch (error) { - console.error('Error while loading layout:', error) - } + setLayoutIndex(dynamic(() => import(`@/themes/${theme}/LayoutIndex`))) } - - loadLayout() + console.log(loadLayout) + // loadLayout() }, [theme]) - return ( - }> - - - ) + return }> + + } /** diff --git a/pages/page/[page].js b/pages/page/[page].js index 252ec566..e3b03ddd 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -3,24 +3,43 @@ import { getPostBlocks } from '@/lib/notion' import { getGlobalNotionData } from '@/lib/notion/getNotionData' import { useGlobal } from '@/lib/global' import dynamic from 'next/dynamic' +import { Suspense, useEffect, useState } from 'react' import Loading from '@/components/Loading' +/** + * 加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutPage`), { ssr: true }) +/** + * 文章列表分页 + * @param {*} props + * @returns + */ const Page = props => { const { theme } = useGlobal() const { siteInfo } = props - if (!siteInfo) { - return <> - } + const [Layout, setLayout] = useState(DefaultLayout) + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutPage`))) + } + loadLayout() + }, [theme]) + const meta = { - title: `${props.page} | Page | ${siteInfo?.title}`, + title: `${props?.page} | Page | ${siteInfo?.title}`, description: siteInfo?.description, image: siteInfo?.pageCover, slug: 'page/' + props.page, type: 'website' } - const LayoutPage = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutPage }), { ssr: true, loading: () => }) - return + props = { ...props, meta } + + return }> + + } export async function getStaticPaths() { diff --git a/pages/search/[keyword]/index.js b/pages/search/[keyword]/index.js index dd81f60f..92b18fb3 100644 --- a/pages/search/[keyword]/index.js +++ b/pages/search/[keyword]/index.js @@ -3,11 +3,26 @@ import { useGlobal } from '@/lib/global' import { getDataFromCache } from '@/lib/cache/cache_manager' import BLOG from '@/blog.config' import dynamic from 'next/dynamic' +import { Suspense, useEffect, useState } from 'react' import Loading from '@/components/Loading' +/** + * 加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutSearch`), { ssr: true }) + const Index = props => { const { keyword, siteInfo } = props - const { locale } = useGlobal() + const { locale, theme } = useGlobal() + const [Layout, setLayout] = useState(DefaultLayout) + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutSearch`))) + } + loadLayout() + }, [theme]) + const meta = { title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteInfo?.title}`, description: siteInfo?.title, @@ -15,10 +30,12 @@ const Index = props => { slug: 'search/' + (keyword || ''), type: 'website' } - const { theme } = useGlobal() - const LayoutSearch = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutSearch }), { ssr: true, loading: () => }) - return + props = { ...props, meta } + + return }> + + } /** diff --git a/pages/search/[keyword]/page/[page].js b/pages/search/[keyword]/page/[page].js index 57ab7163..a279f332 100644 --- a/pages/search/[keyword]/page/[page].js +++ b/pages/search/[keyword]/page/[page].js @@ -3,11 +3,25 @@ import { useGlobal } from '@/lib/global' import { getDataFromCache } from '@/lib/cache/cache_manager' import dynamic from 'next/dynamic' import BLOG from '@/blog.config' +import { Suspense, useEffect, useState } from 'react' import Loading from '@/components/Loading' +/** + * 加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutSearch`), { ssr: true }) + const Index = props => { const { keyword, siteInfo } = props - const { locale } = useGlobal() + const { locale, theme } = useGlobal() + const [Layout, setLayout] = useState(DefaultLayout) + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutSearch`))) + } + loadLayout() + }, [theme]) const meta = { title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteInfo?.title}`, description: siteInfo?.title, @@ -15,9 +29,12 @@ const Index = props => { slug: 'search/' + (keyword || ''), type: 'website' } - const { theme } = useGlobal() - const LayoutSearch = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutSearch }), { ssr: true, loading: () => }) - return + + props = { ...props, meta, currentSearch: keyword } + + return }> + + } /** diff --git a/pages/search/index.js b/pages/search/index.js index a2347808..06fd3984 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -3,10 +3,26 @@ import { useGlobal } from '@/lib/global' import { useRouter } from 'next/router' import BLOG from '@/blog.config' import dynamic from 'next/dynamic' +import { Suspense, useEffect, useState } from 'react' import Loading from '@/components/Loading' +/** + * 加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutSearch`), { ssr: true }) const Search = props => { const { posts, siteInfo } = props + const { theme } = useGlobal() + const [Layout, setLayout] = useState(DefaultLayout) + + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutSearch`))) + } + loadLayout() + }, [theme]) + const router = useRouter() let filteredPosts const keyword = getSearchKey(router) @@ -32,10 +48,11 @@ const Search = props => { type: 'website' } - const { theme } = useGlobal() + props = { ...props, meta, posts: { filteredPosts } } - const LayoutSearch = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutSearch }), { ssr: true, loading: () => }) - return + return }> + + } /** diff --git a/pages/tag/[tag]/index.js b/pages/tag/[tag]/index.js index 1ba4f220..8b5729f3 100644 --- a/pages/tag/[tag]/index.js +++ b/pages/tag/[tag]/index.js @@ -2,17 +2,27 @@ import { useGlobal } from '@/lib/global' import { getGlobalNotionData } from '@/lib/notion/getNotionData' import BLOG from '@/blog.config' import dynamic from 'next/dynamic' +import { Suspense, useEffect, useState } from 'react' import Loading from '@/components/Loading' +/** + * 加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutTag`), { ssr: true }) + const Tag = props => { const { theme } = useGlobal() const { locale } = useGlobal() - const { tag, siteInfo, posts } = props + const { tag, siteInfo } = props + const [Layout, setLayout] = useState(DefaultLayout) - if (!posts) { - const Layout404 = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.Layout404 }), { ssr: true, loading: () => }) - return - } + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutTag`))) + } + loadLayout() + }, [theme]) const meta = { title: `${tag} | ${locale.COMMON.TAGS} | ${siteInfo?.title}`, @@ -21,8 +31,11 @@ const Tag = props => { slug: 'tag/' + tag, type: 'website' } - const LayoutTag = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutTag }), { ssr: true, loading: () => }) - return + props = { ...props, meta } + + return }> + + } export async function getStaticProps({ params: { tag } }) { diff --git a/pages/tag/[tag]/page/[page].js b/pages/tag/[tag]/page/[page].js index c3fc2009..2adb6c2c 100644 --- a/pages/tag/[tag]/page/[page].js +++ b/pages/tag/[tag]/page/[page].js @@ -2,17 +2,26 @@ import { useGlobal } from '@/lib/global' import { getGlobalNotionData } from '@/lib/notion/getNotionData' import BLOG from '@/blog.config' import dynamic from 'next/dynamic' +import { Suspense, useEffect, useState } from 'react' import Loading from '@/components/Loading' +/** + * 加载默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutTag`), { ssr: true }) + const Tag = props => { const { theme } = useGlobal() const { locale } = useGlobal() - const { tag, siteInfo, posts } = props - - if (!posts) { - const Layout404 = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.Layout404 }), { ssr: true, loading: () => }) - return - } + const { tag, siteInfo } = props + const [Layout, setLayout] = useState(DefaultLayout) + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutTag`))) + } + loadLayout() + }, [theme]) const meta = { title: `${tag} | ${locale.COMMON.TAGS} | ${siteInfo?.title}`, @@ -21,8 +30,11 @@ const Tag = props => { slug: 'tag/' + tag, type: 'website' } - const LayoutTag = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutTag }), { ssr: true, loading: () => }) - return + props = { ...props, meta } + + return }> + + } export async function getStaticProps({ params: { tag, page } }) { diff --git a/pages/tag/index.js b/pages/tag/index.js index 3f69551e..8b8bc1c7 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -1,9 +1,13 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData' -import React from 'react' +import { Suspense, useEffect, useState } from 'react' import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import dynamic from 'next/dynamic' import Loading from '@/components/Loading' +/** + * 默认主题 + */ +const DefaultLayout = dynamic(() => import(`@/themes/${BLOG.THEME}/LayoutTagIndex`), { ssr: true }) /** * 标签首页 @@ -11,9 +15,18 @@ import Loading from '@/components/Loading' * @returns */ const TagIndex = props => { - const { theme } = useGlobal() const { locale } = useGlobal() const { siteInfo } = props + const { theme } = useGlobal() + const [Layout, setLayout] = useState(DefaultLayout) + // 切换主题 + useEffect(() => { + const loadLayout = async () => { + setLayout(dynamic(() => import(`@/themes/${theme}/LayoutTagIndex`))) + } + loadLayout() + }, [theme]) + const meta = { title: `${locale.COMMON.TAGS} | ${siteInfo?.title}`, description: siteInfo?.description, @@ -21,8 +34,11 @@ const TagIndex = props => { slug: 'tag', type: 'website' } - const LayoutTagIndex = dynamic(() => import(`@/themes/${theme}`).then(async (m) => { return m.LayoutTagIndex }), { ssr: true, loading: () => }) - return + props = { ...props, meta } + + return }> + + } export async function getStaticProps() { diff --git a/themes/example/Layout404.js b/themes/example/Layout404.js index 5f92f0cc..c0992ad3 100644 --- a/themes/example/Layout404.js +++ b/themes/example/Layout404.js @@ -5,3 +5,5 @@ export const Layout404 = (props) => { 404 Not found. } + +export default Layout404 diff --git a/themes/example/LayoutArchive.js b/themes/example/LayoutArchive.js index 4ba92d8a..81ec0781 100644 --- a/themes/example/LayoutArchive.js +++ b/themes/example/LayoutArchive.js @@ -43,3 +43,5 @@ export const LayoutArchive = props => { ) } + +export default LayoutArchive diff --git a/themes/example/LayoutCategory.js b/themes/example/LayoutCategory.js index 6d819185..517a5e82 100644 --- a/themes/example/LayoutCategory.js +++ b/themes/example/LayoutCategory.js @@ -8,3 +8,5 @@ export const LayoutCategory = props => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutCategory diff --git a/themes/example/LayoutCategoryIndex.js b/themes/example/LayoutCategoryIndex.js index a4c19033..d969516b 100644 --- a/themes/example/LayoutCategoryIndex.js +++ b/themes/example/LayoutCategoryIndex.js @@ -24,3 +24,5 @@ export const LayoutCategoryIndex = props => { ) } + +export default LayoutCategoryIndex diff --git a/themes/example/LayoutIndex.js b/themes/example/LayoutIndex.js index 94eaac2f..18024d9c 100644 --- a/themes/example/LayoutIndex.js +++ b/themes/example/LayoutIndex.js @@ -11,3 +11,5 @@ export const LayoutIndex = props => { ) } + +export default LayoutIndex diff --git a/themes/example/LayoutPage.js b/themes/example/LayoutPage.js index 15355018..184251a8 100644 --- a/themes/example/LayoutPage.js +++ b/themes/example/LayoutPage.js @@ -8,3 +8,5 @@ export const LayoutPage = props => { ) } + +export default LayoutPage diff --git a/themes/example/LayoutSlug.js b/themes/example/LayoutSlug.js index b19f51ff..2ab9c557 100644 --- a/themes/example/LayoutSlug.js +++ b/themes/example/LayoutSlug.js @@ -29,3 +29,5 @@ export const LayoutSlug = props => { ) } + +export default LayoutSlug diff --git a/themes/example/LayoutTag.js b/themes/example/LayoutTag.js index 06a6d778..f12ae546 100644 --- a/themes/example/LayoutTag.js +++ b/themes/example/LayoutTag.js @@ -8,3 +8,5 @@ export const LayoutTag = props => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutTag diff --git a/themes/example/LayoutTagIndex.js b/themes/example/LayoutTagIndex.js index 0705c2d6..63ffa7ca 100644 --- a/themes/example/LayoutTagIndex.js +++ b/themes/example/LayoutTagIndex.js @@ -27,3 +27,5 @@ export const LayoutTagIndex = (props) => {
) } + +export default LayoutTagIndex diff --git a/themes/example/index.js b/themes/example/index.js deleted file mode 100644 index dd762bd4..00000000 --- a/themes/example/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import CONFIG_EXAMPLE from './config_example' -import { LayoutIndex } from './LayoutIndex' -import { LayoutSearch } from './LayoutSearch' -import { LayoutArchive } from './LayoutArchive' -import { LayoutSlug } from './LayoutSlug' -import { Layout404 } from './Layout404' -import { LayoutCategory } from './LayoutCategory' -import { LayoutCategoryIndex } from './LayoutCategoryIndex' -import { LayoutPage } from './LayoutPage' -import { LayoutTag } from './LayoutTag' -import { LayoutTagIndex } from './LayoutTagIndex' - -export { - CONFIG_EXAMPLE as THEME_CONFIG, - LayoutIndex, - LayoutSearch, - LayoutArchive, - LayoutSlug, - Layout404, - LayoutCategory, - LayoutCategoryIndex, - LayoutPage, - LayoutTag, - LayoutTagIndex -} diff --git a/themes/fukasawa/Layout404.js b/themes/fukasawa/Layout404.js index 183001c9..98ae689a 100644 --- a/themes/fukasawa/Layout404.js +++ b/themes/fukasawa/Layout404.js @@ -3,3 +3,5 @@ import LayoutBase from './LayoutBase' export const Layout404 = props => { return 404 } + +export default Layout404 diff --git a/themes/fukasawa/LayoutArchive.js b/themes/fukasawa/LayoutArchive.js index 495ed6a4..f82f3e35 100644 --- a/themes/fukasawa/LayoutArchive.js +++ b/themes/fukasawa/LayoutArchive.js @@ -28,3 +28,5 @@ export const LayoutArchive = (props) => { } + +export default LayoutArchive diff --git a/themes/fukasawa/LayoutCategory.js b/themes/fukasawa/LayoutCategory.js index fa6c8c0d..c633a439 100644 --- a/themes/fukasawa/LayoutCategory.js +++ b/themes/fukasawa/LayoutCategory.js @@ -8,3 +8,5 @@ export const LayoutCategory = props => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutCategory diff --git a/themes/fukasawa/LayoutCategoryIndex.js b/themes/fukasawa/LayoutCategoryIndex.js index 9e9cdd9c..469ab973 100644 --- a/themes/fukasawa/LayoutCategoryIndex.js +++ b/themes/fukasawa/LayoutCategoryIndex.js @@ -31,3 +31,5 @@ export const LayoutCategoryIndex = (props) => { ) } + +export default LayoutCategoryIndex diff --git a/themes/fukasawa/LayoutIndex.js b/themes/fukasawa/LayoutIndex.js index 47ae1bce..d4e7451b 100644 --- a/themes/fukasawa/LayoutIndex.js +++ b/themes/fukasawa/LayoutIndex.js @@ -8,3 +8,5 @@ export const LayoutIndex = (props) => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutIndex diff --git a/themes/fukasawa/LayoutPage.js b/themes/fukasawa/LayoutPage.js index a3c39788..c3a85397 100644 --- a/themes/fukasawa/LayoutPage.js +++ b/themes/fukasawa/LayoutPage.js @@ -8,3 +8,5 @@ export const LayoutPage = (props) => { } + +export default LayoutPage diff --git a/themes/fukasawa/LayoutSearch.js b/themes/fukasawa/LayoutSearch.js index fcfa35b2..58aeaf88 100644 --- a/themes/fukasawa/LayoutSearch.js +++ b/themes/fukasawa/LayoutSearch.js @@ -28,3 +28,5 @@ export const LayoutSearch = (props) => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutSearch diff --git a/themes/fukasawa/LayoutSlug.js b/themes/fukasawa/LayoutSlug.js index fb78690c..73e22a00 100644 --- a/themes/fukasawa/LayoutSlug.js +++ b/themes/fukasawa/LayoutSlug.js @@ -11,3 +11,5 @@ export const LayoutSlug = (props) => { ) } + +export default LayoutSlug diff --git a/themes/fukasawa/LayoutTag.js b/themes/fukasawa/LayoutTag.js index 46e9e0fd..104b6884 100644 --- a/themes/fukasawa/LayoutTag.js +++ b/themes/fukasawa/LayoutTag.js @@ -1,7 +1,6 @@ import BLOG from '@/blog.config' import BlogListPage from './components/BlogListPage' import BlogListScroll from './components/BlogListScroll' -import TagItemMini from './components/TagItemMini' import LayoutBase from './LayoutBase' export const LayoutTag = (props) => { @@ -9,3 +8,5 @@ export const LayoutTag = (props) => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutTag diff --git a/themes/fukasawa/LayoutTagIndex.js b/themes/fukasawa/LayoutTagIndex.js index df43fdeb..30f602a6 100644 --- a/themes/fukasawa/LayoutTagIndex.js +++ b/themes/fukasawa/LayoutTagIndex.js @@ -1,5 +1,4 @@ import { useGlobal } from '@/lib/global' -import TagItem from './components/TagItem' import TagItemMini from './components/TagItemMini' import LayoutBase from './LayoutBase' @@ -21,3 +20,5 @@ export const LayoutTagIndex = (props) => { } + +export default LayoutTagIndex diff --git a/themes/fukasawa/index.js b/themes/fukasawa/index.js deleted file mode 100644 index 58968469..00000000 --- a/themes/fukasawa/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import CONFIG_FUKA from './config_fuka' -import { LayoutIndex } from './LayoutIndex' -import { LayoutSearch } from './LayoutSearch' -import { LayoutArchive } from './LayoutArchive' -import { LayoutSlug } from './LayoutSlug' -import { Layout404 } from './Layout404' -import { LayoutCategory } from './LayoutCategory' -import { LayoutCategoryIndex } from './LayoutCategoryIndex' -import { LayoutPage } from './LayoutPage' -import { LayoutTag } from './LayoutTag' -import { LayoutTagIndex } from './LayoutTagIndex' - -export { - CONFIG_FUKA as THEME_CONFIG, - LayoutIndex, - LayoutSearch, - LayoutArchive, - LayoutSlug, - Layout404, - LayoutCategory, - LayoutCategoryIndex, - LayoutPage, - LayoutTag, - LayoutTagIndex -} diff --git a/themes/hexo/Layout404.js b/themes/hexo/Layout404.js index 609b6e7c..fcf2bf2c 100644 --- a/themes/hexo/Layout404.js +++ b/themes/hexo/Layout404.js @@ -30,3 +30,4 @@ export const Layout404 = props => { ) } +export default Layout404 diff --git a/themes/hexo/LayoutArchive.js b/themes/hexo/LayoutArchive.js index 94dc9267..44f81c08 100644 --- a/themes/hexo/LayoutArchive.js +++ b/themes/hexo/LayoutArchive.js @@ -32,3 +32,5 @@ export const LayoutArchive = (props) => { } + +export default LayoutArchive diff --git a/themes/hexo/LayoutCategory.js b/themes/hexo/LayoutCategory.js index 7df32650..3aedefef 100644 --- a/themes/hexo/LayoutCategory.js +++ b/themes/hexo/LayoutCategory.js @@ -13,3 +13,5 @@ export const LayoutCategory = props => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutCategory diff --git a/themes/hexo/LayoutCategoryIndex.js b/themes/hexo/LayoutCategoryIndex.js index 0d0a24d0..bd4e278e 100644 --- a/themes/hexo/LayoutCategoryIndex.js +++ b/themes/hexo/LayoutCategoryIndex.js @@ -37,3 +37,5 @@ export const LayoutCategoryIndex = props => { ) } + +export default LayoutCategoryIndex diff --git a/themes/hexo/LayoutIndex.js b/themes/hexo/LayoutIndex.js index 48cc29e4..388e69bf 100644 --- a/themes/hexo/LayoutIndex.js +++ b/themes/hexo/LayoutIndex.js @@ -12,3 +12,5 @@ export const LayoutIndex = (props) => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutIndex diff --git a/themes/hexo/LayoutPage.js b/themes/hexo/LayoutPage.js index ac32c985..58d35c0a 100644 --- a/themes/hexo/LayoutPage.js +++ b/themes/hexo/LayoutPage.js @@ -6,3 +6,5 @@ export const LayoutPage = (props) => { } + +export default LayoutPage diff --git a/themes/hexo/LayoutSearch.js b/themes/hexo/LayoutSearch.js index bf9c6daa..1098e483 100644 --- a/themes/hexo/LayoutSearch.js +++ b/themes/hexo/LayoutSearch.js @@ -97,3 +97,5 @@ export const LayoutSearch = props => { ) } + +export default LayoutSearch diff --git a/themes/hexo/LayoutSlug.js b/themes/hexo/LayoutSlug.js index 120d4243..9c8ff361 100644 --- a/themes/hexo/LayoutSlug.js +++ b/themes/hexo/LayoutSlug.js @@ -93,3 +93,5 @@ export const LayoutSlug = props => { ) } + +export default LayoutSlug diff --git a/themes/hexo/LayoutTag.js b/themes/hexo/LayoutTag.js index 36a9ce7d..fa63df85 100644 --- a/themes/hexo/LayoutTag.js +++ b/themes/hexo/LayoutTag.js @@ -30,3 +30,5 @@ export const LayoutTag = (props) => { ) } + +export default LayoutTag diff --git a/themes/hexo/LayoutTagIndex.js b/themes/hexo/LayoutTagIndex.js index 5e83966a..40e7e234 100644 --- a/themes/hexo/LayoutTagIndex.js +++ b/themes/hexo/LayoutTagIndex.js @@ -26,3 +26,5 @@ export const LayoutTagIndex = props => { ) } + +export default LayoutTagIndex diff --git a/themes/hexo/index.js b/themes/hexo/index.js deleted file mode 100644 index 8528d5da..00000000 --- a/themes/hexo/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import CONFIG_HEXO from './config_hexo' -import { LayoutIndex } from './LayoutIndex' -import { LayoutSearch } from './LayoutSearch' -import { LayoutArchive } from './LayoutArchive' -import { LayoutSlug } from './LayoutSlug' -import { Layout404 } from './Layout404' -import { LayoutCategory } from './LayoutCategory' -import { LayoutCategoryIndex } from './LayoutCategoryIndex' -import { LayoutPage } from './LayoutPage' -import { LayoutTag } from './LayoutTag' -import { LayoutTagIndex } from './LayoutTagIndex' - -export { - CONFIG_HEXO as THEME_CONFIG, - LayoutIndex, - LayoutSearch, - LayoutArchive, - LayoutSlug, - Layout404, - LayoutCategory, - LayoutCategoryIndex, - LayoutPage, - LayoutTag, - LayoutTagIndex -} diff --git a/themes/matery/Layout404.js b/themes/matery/Layout404.js index 609b6e7c..21fcade3 100644 --- a/themes/matery/Layout404.js +++ b/themes/matery/Layout404.js @@ -30,3 +30,5 @@ export const Layout404 = props => { ) } + +export default Layout404 diff --git a/themes/matery/LayoutArchive.js b/themes/matery/LayoutArchive.js index 49accca0..94b40239 100644 --- a/themes/matery/LayoutArchive.js +++ b/themes/matery/LayoutArchive.js @@ -32,3 +32,5 @@ export const LayoutArchive = (props) => { } + +export default LayoutArchive diff --git a/themes/matery/LayoutCategory.js b/themes/matery/LayoutCategory.js index 6e9524ab..a50f3a40 100644 --- a/themes/matery/LayoutCategory.js +++ b/themes/matery/LayoutCategory.js @@ -36,3 +36,5 @@ export const LayoutCategory = props => { ) } + +export default LayoutCategory diff --git a/themes/matery/LayoutCategoryIndex.js b/themes/matery/LayoutCategoryIndex.js index b6eda2bb..f6fd0023 100644 --- a/themes/matery/LayoutCategoryIndex.js +++ b/themes/matery/LayoutCategoryIndex.js @@ -30,3 +30,5 @@ export const LayoutCategoryIndex = props => { ) } + +export default LayoutCategoryIndex diff --git a/themes/matery/LayoutIndex.js b/themes/matery/LayoutIndex.js index a25c360a..6c92d2c4 100644 --- a/themes/matery/LayoutIndex.js +++ b/themes/matery/LayoutIndex.js @@ -12,3 +12,5 @@ export const LayoutIndex = (props) => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutIndex diff --git a/themes/matery/LayoutPage.js b/themes/matery/LayoutPage.js index b0841c1c..e3d72944 100644 --- a/themes/matery/LayoutPage.js +++ b/themes/matery/LayoutPage.js @@ -6,3 +6,5 @@ export const LayoutPage = (props) => { } + +export default LayoutPage diff --git a/themes/matery/LayoutSearch.js b/themes/matery/LayoutSearch.js index 94ccbb96..10df7b11 100644 --- a/themes/matery/LayoutSearch.js +++ b/themes/matery/LayoutSearch.js @@ -97,3 +97,5 @@ export const LayoutSearch = props => { ) } + +export default LayoutSearch diff --git a/themes/matery/LayoutSlug.js b/themes/matery/LayoutSlug.js index 362e8be4..6e98ceb3 100644 --- a/themes/matery/LayoutSlug.js +++ b/themes/matery/LayoutSlug.js @@ -128,3 +128,5 @@ export const LayoutSlug = props => { ) } + +export default LayoutSlug diff --git a/themes/matery/LayoutTag.js b/themes/matery/LayoutTag.js index 4f0ac66b..1a2e9054 100644 --- a/themes/matery/LayoutTag.js +++ b/themes/matery/LayoutTag.js @@ -6,7 +6,6 @@ import React from 'react' import HeaderArticle from './components/HeaderArticle' import { useGlobal } from '@/lib/global' import TagItemMiddle from './components/TagItemMiddle' -import TagItemMini from './components/TagItemMini' export const LayoutTag = (props) => { const { tagOptions, tag } = props @@ -41,3 +40,5 @@ export const LayoutTag = (props) => { } + +export default LayoutTag diff --git a/themes/matery/LayoutTagIndex.js b/themes/matery/LayoutTagIndex.js index d1d19835..f25ba122 100644 --- a/themes/matery/LayoutTagIndex.js +++ b/themes/matery/LayoutTagIndex.js @@ -1,7 +1,6 @@ import { useGlobal } from '@/lib/global' import HeaderArticle from './components/HeaderArticle' import TagItemMiddle from './components/TagItemMiddle' -import TagItemMini from './components/TagItemMini' import LayoutBase from './LayoutBase' export const LayoutTagIndex = props => { @@ -31,3 +30,5 @@ export const LayoutTagIndex = props => { ) } + +export default LayoutTagIndex diff --git a/themes/matery/index.js b/themes/matery/index.js deleted file mode 100644 index 528e1e80..00000000 --- a/themes/matery/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import CONFIG_MATERY from './config_matery' -import { LayoutIndex } from './LayoutIndex' -import { LayoutSearch } from './LayoutSearch' -import { LayoutArchive } from './LayoutArchive' -import { LayoutSlug } from './LayoutSlug' -import { Layout404 } from './Layout404' -import { LayoutCategory } from './LayoutCategory' -import { LayoutCategoryIndex } from './LayoutCategoryIndex' -import { LayoutPage } from './LayoutPage' -import { LayoutTag } from './LayoutTag' -import { LayoutTagIndex } from './LayoutTagIndex' - -export { - CONFIG_MATERY as THEME_CONFIG, - LayoutIndex, - LayoutSearch, - LayoutArchive, - LayoutSlug, - Layout404, - LayoutCategory, - LayoutCategoryIndex, - LayoutPage, - LayoutTag, - LayoutTagIndex -} diff --git a/themes/medium/Layout404.js b/themes/medium/Layout404.js index 02cdc048..68b656cc 100644 --- a/themes/medium/Layout404.js +++ b/themes/medium/Layout404.js @@ -5,3 +5,5 @@ export const Layout404 = props => {
404 Not found.
} + +export default Layout404 diff --git a/themes/medium/LayoutArchive.js b/themes/medium/LayoutArchive.js index a1449b72..101b7119 100644 --- a/themes/medium/LayoutArchive.js +++ b/themes/medium/LayoutArchive.js @@ -45,3 +45,5 @@ export const LayoutArchive = props => { ) } + +export default LayoutArchive diff --git a/themes/medium/LayoutCategory.js b/themes/medium/LayoutCategory.js index c20a4cde..a947b70e 100644 --- a/themes/medium/LayoutCategory.js +++ b/themes/medium/LayoutCategory.js @@ -11,3 +11,5 @@ export const LayoutCategory = props => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutCategory diff --git a/themes/medium/LayoutCategoryIndex.js b/themes/medium/LayoutCategoryIndex.js index c9c79254..2c8121ad 100644 --- a/themes/medium/LayoutCategoryIndex.js +++ b/themes/medium/LayoutCategoryIndex.js @@ -31,3 +31,4 @@ export const LayoutCategoryIndex = (props) => { ) } +export default LayoutCategoryIndex diff --git a/themes/medium/LayoutIndex.js b/themes/medium/LayoutIndex.js index 35e80571..41410467 100644 --- a/themes/medium/LayoutIndex.js +++ b/themes/medium/LayoutIndex.js @@ -8,3 +8,5 @@ export const LayoutIndex = (props) => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutIndex diff --git a/themes/medium/LayoutPage.js b/themes/medium/LayoutPage.js index cec493ce..563df90b 100644 --- a/themes/medium/LayoutPage.js +++ b/themes/medium/LayoutPage.js @@ -6,3 +6,5 @@ export const LayoutPage = (props) => { } + +export default LayoutPage diff --git a/themes/medium/LayoutSearch.js b/themes/medium/LayoutSearch.js index 0ff29b6d..1aaf3d20 100644 --- a/themes/medium/LayoutSearch.js +++ b/themes/medium/LayoutSearch.js @@ -49,3 +49,5 @@ export const LayoutSearch = (props) => { } } + +export default LayoutSearch diff --git a/themes/medium/LayoutSlug.js b/themes/medium/LayoutSlug.js index 401c4a03..dab24ed0 100644 --- a/themes/medium/LayoutSlug.js +++ b/themes/medium/LayoutSlug.js @@ -106,3 +106,5 @@ export const LayoutSlug = props => { ) } + +export default LayoutSlug diff --git a/themes/medium/LayoutTag.js b/themes/medium/LayoutTag.js index 51a7ca59..bedb51ef 100644 --- a/themes/medium/LayoutTag.js +++ b/themes/medium/LayoutTag.js @@ -11,3 +11,5 @@ export const LayoutTag = (props) => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutTag diff --git a/themes/medium/LayoutTagIndex.js b/themes/medium/LayoutTagIndex.js index 1f173bd2..cc9f8c94 100644 --- a/themes/medium/LayoutTagIndex.js +++ b/themes/medium/LayoutTagIndex.js @@ -25,3 +25,5 @@ export const LayoutTagIndex = props => { ) } + +export default LayoutTagIndex diff --git a/themes/medium/index.js b/themes/medium/index.js deleted file mode 100644 index 81961c58..00000000 --- a/themes/medium/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import CONFIG_MEDIUM from './config_medium' -import { LayoutIndex } from './LayoutIndex' -import { LayoutSearch } from './LayoutSearch' -import { LayoutArchive } from './LayoutArchive' -import { LayoutSlug } from './LayoutSlug' -import { Layout404 } from './Layout404' -import { LayoutCategory } from './LayoutCategory' -import { LayoutCategoryIndex } from './LayoutCategoryIndex' -import { LayoutPage } from './LayoutPage' -import { LayoutTag } from './LayoutTag' -import { LayoutTagIndex } from './LayoutTagIndex' - -export { - CONFIG_MEDIUM as THEME_CONFIG, - LayoutIndex, - LayoutSearch, - LayoutArchive, - LayoutSlug, - Layout404, - LayoutCategory, - LayoutCategoryIndex, - LayoutPage, - LayoutTag, - LayoutTagIndex -} diff --git a/themes/next/Layout404.js b/themes/next/Layout404.js index 8c1bc421..61c48d37 100644 --- a/themes/next/Layout404.js +++ b/themes/next/Layout404.js @@ -29,3 +29,4 @@ export const Layout404 = props => { } +export default Layout404 diff --git a/themes/next/LayoutArchive.js b/themes/next/LayoutArchive.js index ebd94ed3..29f6683c 100644 --- a/themes/next/LayoutArchive.js +++ b/themes/next/LayoutArchive.js @@ -31,3 +31,5 @@ export const LayoutArchive = (props) => { ) } + +export default LayoutArchive diff --git a/themes/next/LayoutCategory.js b/themes/next/LayoutCategory.js index ec71cb95..aaf07970 100644 --- a/themes/next/LayoutCategory.js +++ b/themes/next/LayoutCategory.js @@ -19,3 +19,5 @@ export const LayoutCategory = (props) => { } + +export default LayoutCategory diff --git a/themes/next/LayoutCategoryIndex.js b/themes/next/LayoutCategoryIndex.js index 0dd99e0f..ca7d992a 100644 --- a/themes/next/LayoutCategoryIndex.js +++ b/themes/next/LayoutCategoryIndex.js @@ -31,3 +31,5 @@ export const LayoutCategoryIndex = (props) => { ) } + +export default LayoutCategoryIndex diff --git a/themes/next/LayoutIndex.js b/themes/next/LayoutIndex.js index c43dc3d3..31cfee1c 100644 --- a/themes/next/LayoutIndex.js +++ b/themes/next/LayoutIndex.js @@ -18,7 +18,10 @@ export const LayoutIndex = (props) => { > {BLOG.POST_LIST_STYLE !== 'page' ? - : + : } } + +export default LayoutIndex diff --git a/themes/next/LayoutPage.js b/themes/next/LayoutPage.js index 7cd06dab..710392fd 100644 --- a/themes/next/LayoutPage.js +++ b/themes/next/LayoutPage.js @@ -15,3 +15,5 @@ export const LayoutPage = (props) => { ) } + +export default LayoutPage diff --git a/themes/next/LayoutSearch.js b/themes/next/LayoutSearch.js index 78664343..31e102fd 100644 --- a/themes/next/LayoutSearch.js +++ b/themes/next/LayoutSearch.js @@ -37,3 +37,5 @@ export const LayoutSearch = (props) => { ) } + +export default LayoutSearch diff --git a/themes/next/LayoutSlug.js b/themes/next/LayoutSlug.js index 0087bf93..9870d457 100644 --- a/themes/next/LayoutSlug.js +++ b/themes/next/LayoutSlug.js @@ -40,3 +40,5 @@ export const LayoutSlug = (props) => { ) } + +export default LayoutSlug diff --git a/themes/next/LayoutTag.js b/themes/next/LayoutTag.js index c70307e8..9bf9b0c4 100644 --- a/themes/next/LayoutTag.js +++ b/themes/next/LayoutTag.js @@ -20,3 +20,5 @@ export const LayoutTag = (props) => { } + +export default LayoutTag diff --git a/themes/next/LayoutTagIndex.js b/themes/next/LayoutTagIndex.js index 5278dd8f..a8e96067 100644 --- a/themes/next/LayoutTagIndex.js +++ b/themes/next/LayoutTagIndex.js @@ -16,3 +16,5 @@ export const LayoutTagIndex = (props) => { } + +export default LayoutTagIndex diff --git a/themes/next/components/ArticleDetail.js b/themes/next/components/ArticleDetail.js index c0c2efac..da882db9 100644 --- a/themes/next/components/ArticleDetail.js +++ b/themes/next/components/ArticleDetail.js @@ -20,9 +20,10 @@ import NotionIcon from '@/components/NotionIcon' * @returns */ export default function ArticleDetail(props) { - const { post, recommendPosts, prev, next, showArticleInfo } = props + const { post, recommendPosts, prev, next } = props const url = BLOG.LINK + useRouter().asPath const { locale } = useGlobal() + const showArticleInfo = CONFIG_NEXT.ARTICLE_INFO const date = formatDate(post?.date?.start_date || post?.createdTime, locale.LOCALE) return ( diff --git a/themes/next/config_next.js b/themes/next/config_next.js index d341cee0..b1f311a3 100644 --- a/themes/next/config_next.js +++ b/themes/next/config_next.js @@ -31,7 +31,8 @@ const CONFIG_NEXT = { WIDGET_TOC: true, // 移动端显示悬浮目录 ARTICLE_RELATE_POSTS: true, // 相关文章推荐 - ARTICLE_COPYRIGHT: true // 文章版权声明 + ARTICLE_COPYRIGHT: true, // 文章版权声明 + ARTICLE_INFO: true // 显示文章信息 } diff --git a/themes/next/index.js b/themes/next/index.js deleted file mode 100644 index 45286719..00000000 --- a/themes/next/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import CONFIG_NEXT from './config_next' -import { LayoutIndex } from './LayoutIndex' -import { LayoutSearch } from './LayoutSearch' -import { LayoutArchive } from './LayoutArchive' -import { LayoutSlug } from './LayoutSlug' -import { Layout404 } from './Layout404' -import { LayoutCategory } from './LayoutCategory' -import { LayoutCategoryIndex } from './LayoutCategoryIndex' -import { LayoutPage } from './LayoutPage' -import { LayoutTag } from './LayoutTag' -import { LayoutTagIndex } from './LayoutTagIndex' - -export { - CONFIG_NEXT as THEME_CONFIG, - LayoutIndex, - LayoutSearch, - LayoutArchive, - LayoutSlug, - Layout404, - LayoutCategory, - LayoutCategoryIndex, - LayoutPage, - LayoutTag, - LayoutTagIndex -} diff --git a/themes/nobelium/Layout404.js b/themes/nobelium/Layout404.js index 5f92f0cc..c0992ad3 100644 --- a/themes/nobelium/Layout404.js +++ b/themes/nobelium/Layout404.js @@ -5,3 +5,5 @@ export const Layout404 = (props) => { 404 Not found. } + +export default Layout404 diff --git a/themes/nobelium/LayoutArchive.js b/themes/nobelium/LayoutArchive.js index 4ba92d8a..81ec0781 100644 --- a/themes/nobelium/LayoutArchive.js +++ b/themes/nobelium/LayoutArchive.js @@ -43,3 +43,5 @@ export const LayoutArchive = props => { ) } + +export default LayoutArchive diff --git a/themes/nobelium/LayoutCategory.js b/themes/nobelium/LayoutCategory.js index 6d819185..517a5e82 100644 --- a/themes/nobelium/LayoutCategory.js +++ b/themes/nobelium/LayoutCategory.js @@ -8,3 +8,5 @@ export const LayoutCategory = props => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutCategory diff --git a/themes/nobelium/LayoutCategoryIndex.js b/themes/nobelium/LayoutCategoryIndex.js index 3cf9c10d..6a4f255d 100644 --- a/themes/nobelium/LayoutCategoryIndex.js +++ b/themes/nobelium/LayoutCategoryIndex.js @@ -25,3 +25,5 @@ export const LayoutCategoryIndex = (props) => { ) } + +export default LayoutCategoryIndex diff --git a/themes/nobelium/LayoutIndex.js b/themes/nobelium/LayoutIndex.js index 8bf7541a..d1e74923 100644 --- a/themes/nobelium/LayoutIndex.js +++ b/themes/nobelium/LayoutIndex.js @@ -13,3 +13,5 @@ export const LayoutIndex = props => { ) } + +export default LayoutIndex diff --git a/themes/nobelium/LayoutPage.js b/themes/nobelium/LayoutPage.js index 15355018..184251a8 100644 --- a/themes/nobelium/LayoutPage.js +++ b/themes/nobelium/LayoutPage.js @@ -8,3 +8,5 @@ export const LayoutPage = props => { ) } + +export default LayoutPage diff --git a/themes/nobelium/LayoutSearch.js b/themes/nobelium/LayoutSearch.js index 2da4772c..b1995820 100644 --- a/themes/nobelium/LayoutSearch.js +++ b/themes/nobelium/LayoutSearch.js @@ -54,3 +54,5 @@ export const LayoutSearch = props => { } + +export default LayoutSearch diff --git a/themes/nobelium/LayoutSlug.js b/themes/nobelium/LayoutSlug.js index d27628af..ea2cfb3a 100644 --- a/themes/nobelium/LayoutSlug.js +++ b/themes/nobelium/LayoutSlug.js @@ -31,3 +31,5 @@ export const LayoutSlug = props => { ) } + +export default LayoutSlug diff --git a/themes/nobelium/LayoutTag.js b/themes/nobelium/LayoutTag.js index 2d85004b..55607f00 100644 --- a/themes/nobelium/LayoutTag.js +++ b/themes/nobelium/LayoutTag.js @@ -55,3 +55,5 @@ export const LayoutTag = props => { } + +export default LayoutTag diff --git a/themes/nobelium/LayoutTagIndex.js b/themes/nobelium/LayoutTagIndex.js index 0705c2d6..63ffa7ca 100644 --- a/themes/nobelium/LayoutTagIndex.js +++ b/themes/nobelium/LayoutTagIndex.js @@ -27,3 +27,5 @@ export const LayoutTagIndex = (props) => { ) } + +export default LayoutTagIndex diff --git a/themes/nobelium/index.js b/themes/nobelium/index.js deleted file mode 100644 index dda0f1a2..00000000 --- a/themes/nobelium/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import CONFIG_NOBELIUM from './config_nobelium' -import { LayoutIndex } from './LayoutIndex' -import { LayoutSearch } from './LayoutSearch' -import { LayoutArchive } from './LayoutArchive' -import { LayoutSlug } from './LayoutSlug' -import { Layout404 } from './Layout404' -import { LayoutCategory } from './LayoutCategory' -import { LayoutCategoryIndex } from './LayoutCategoryIndex' -import { LayoutPage } from './LayoutPage' -import { LayoutTag } from './LayoutTag' -import { LayoutTagIndex } from './LayoutTagIndex' - -export { - CONFIG_NOBELIUM as THEME_CONFIG, - LayoutIndex, - LayoutSearch, - LayoutArchive, - LayoutSlug, - Layout404, - LayoutCategory, - LayoutCategoryIndex, - LayoutPage, - LayoutTag, - LayoutTagIndex -} diff --git a/themes/simple/Layout404.js b/themes/simple/Layout404.js index 5f92f0cc..c0992ad3 100644 --- a/themes/simple/Layout404.js +++ b/themes/simple/Layout404.js @@ -5,3 +5,5 @@ export const Layout404 = (props) => { 404 Not found. } + +export default Layout404 diff --git a/themes/simple/LayoutArchive.js b/themes/simple/LayoutArchive.js index 4ba92d8a..81ec0781 100644 --- a/themes/simple/LayoutArchive.js +++ b/themes/simple/LayoutArchive.js @@ -43,3 +43,5 @@ export const LayoutArchive = props => { ) } + +export default LayoutArchive diff --git a/themes/simple/LayoutCategory.js b/themes/simple/LayoutCategory.js index 6d819185..517a5e82 100644 --- a/themes/simple/LayoutCategory.js +++ b/themes/simple/LayoutCategory.js @@ -8,3 +8,5 @@ export const LayoutCategory = props => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutCategory diff --git a/themes/simple/LayoutCategoryIndex.js b/themes/simple/LayoutCategoryIndex.js index a4c19033..d969516b 100644 --- a/themes/simple/LayoutCategoryIndex.js +++ b/themes/simple/LayoutCategoryIndex.js @@ -24,3 +24,5 @@ export const LayoutCategoryIndex = props => { ) } + +export default LayoutCategoryIndex diff --git a/themes/simple/LayoutIndex.js b/themes/simple/LayoutIndex.js index 94eaac2f..18024d9c 100644 --- a/themes/simple/LayoutIndex.js +++ b/themes/simple/LayoutIndex.js @@ -11,3 +11,5 @@ export const LayoutIndex = props => { ) } + +export default LayoutIndex diff --git a/themes/simple/LayoutPage.js b/themes/simple/LayoutPage.js index 15355018..184251a8 100644 --- a/themes/simple/LayoutPage.js +++ b/themes/simple/LayoutPage.js @@ -8,3 +8,5 @@ export const LayoutPage = props => { ) } + +export default LayoutPage diff --git a/themes/simple/LayoutSearch.js b/themes/simple/LayoutSearch.js index 1ba8fef7..597e7c25 100644 --- a/themes/simple/LayoutSearch.js +++ b/themes/simple/LayoutSearch.js @@ -48,3 +48,5 @@ export const LayoutSearch = props => { } + +export default LayoutSearch diff --git a/themes/simple/LayoutSlug.js b/themes/simple/LayoutSlug.js index 96f42c3e..4f6fc66f 100644 --- a/themes/simple/LayoutSlug.js +++ b/themes/simple/LayoutSlug.js @@ -33,3 +33,5 @@ export const LayoutSlug = props => { ) } + +export default LayoutSlug diff --git a/themes/simple/LayoutTag.js b/themes/simple/LayoutTag.js index 06a6d778..f12ae546 100644 --- a/themes/simple/LayoutTag.js +++ b/themes/simple/LayoutTag.js @@ -8,3 +8,5 @@ export const LayoutTag = props => { {BLOG.POST_LIST_STYLE === 'page' ? : } } + +export default LayoutTag diff --git a/themes/simple/LayoutTagIndex.js b/themes/simple/LayoutTagIndex.js index 0705c2d6..63ffa7ca 100644 --- a/themes/simple/LayoutTagIndex.js +++ b/themes/simple/LayoutTagIndex.js @@ -27,3 +27,5 @@ export const LayoutTagIndex = (props) => { ) } + +export default LayoutTagIndex diff --git a/themes/simple/index.js b/themes/simple/index.js deleted file mode 100644 index 7e560470..00000000 --- a/themes/simple/index.js +++ /dev/null @@ -1,25 +0,0 @@ -import CONFIG_SIMPLE from './config_simple' -import { LayoutIndex } from './LayoutIndex' -import { LayoutSearch } from './LayoutSearch' -import { LayoutArchive } from './LayoutArchive' -import { LayoutSlug } from './LayoutSlug' -import { Layout404 } from './Layout404' -import { LayoutCategory } from './LayoutCategory' -import { LayoutCategoryIndex } from './LayoutCategoryIndex' -import { LayoutPage } from './LayoutPage' -import { LayoutTag } from './LayoutTag' -import { LayoutTagIndex } from './LayoutTagIndex' - -export { - CONFIG_SIMPLE as THEME_CONFIG, - LayoutIndex, - LayoutSearch, - LayoutArchive, - LayoutSlug, - Layout404, - LayoutCategory, - LayoutCategoryIndex, - LayoutPage, - LayoutTag, - LayoutTagIndex -}