From d5235b3e44f58e8ac10439aa6a9a556e0de827d8 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Thu, 21 Nov 2024 12:28:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/{GlobalHead.js => SEO.js} | 4 +- lib/sitemap.xml.js | 6 ++- pages/_app.js | 4 +- themes/heo/index.js | 2 +- themes/magzine/components/BannerItem.js | 17 ++++---- themes/magzine/components/CTA.js | 2 +- themes/magzine/index.js | 54 ++++++++++++++----------- themes/medium/index.js | 6 ++- 8 files changed, 55 insertions(+), 40 deletions(-) rename components/{GlobalHead.js => SEO.js} (99%) diff --git a/components/GlobalHead.js b/components/SEO.js similarity index 99% rename from components/GlobalHead.js rename to components/SEO.js index 0bd3dcca..592154db 100644 --- a/components/GlobalHead.js +++ b/components/SEO.js @@ -10,7 +10,7 @@ import { useEffect } from 'react' * @param {*} param0 * @returns */ -const GlobalHead = props => { +const SEO = props => { const { children, siteInfo, post, NOTION_CONFIG } = props let url = siteConfig('PATH')?.length ? `${siteConfig('LINK')}/${siteConfig('SUB_PATH', '')}` @@ -275,4 +275,4 @@ const getSEOMeta = (props, router, locale) => { } } -export default GlobalHead +export default SEO diff --git a/lib/sitemap.xml.js b/lib/sitemap.xml.js index 7ec05518..fde90c88 100644 --- a/lib/sitemap.xml.js +++ b/lib/sitemap.xml.js @@ -10,12 +10,14 @@ export async function generateSitemapXml({ allPages, NOTION_CONFIG }) { { loc: `${link}`, lastmod: new Date().toISOString().split('T')[0], - changefreq: 'daily' + changefreq: 'daily', + priority: 1.0 }, { loc: `${link}/archive`, lastmod: new Date().toISOString().split('T')[0], - changefreq: 'daily' + changefreq: 'daily', + priority: 1.0 }, { loc: `${link}/category`, diff --git a/pages/_app.js b/pages/_app.js index 12002916..80333a64 100644 --- a/pages/_app.js +++ b/pages/_app.js @@ -16,7 +16,7 @@ import { getQueryParam } from '../lib/utils' // 各种扩展插件 这个要阻塞引入 import BLOG from '@/blog.config' import ExternalPlugins from '@/components/ExternalPlugins' -import GlobalHead from '@/components/GlobalHead' +import SEO from '@/components/SEO' import { zhCN } from '@clerk/localizations' import dynamic from 'next/dynamic' // import { ClerkProvider } from '@clerk/nextjs' @@ -55,7 +55,7 @@ const MyApp = ({ Component, pageProps }) => { const content = ( - + diff --git a/themes/heo/index.js b/themes/heo/index.js index 3df48ce4..b3c966ed 100644 --- a/themes/heo/index.js +++ b/themes/heo/index.js @@ -194,7 +194,7 @@ const LayoutSearch = props => { } }, []) return ( -
+
{!currentSearch ? ( diff --git a/themes/magzine/components/BannerItem.js b/themes/magzine/components/BannerItem.js index 3e77271a..1d4fdcfb 100644 --- a/themes/magzine/components/BannerItem.js +++ b/themes/magzine/components/BannerItem.js @@ -1,5 +1,6 @@ import { siteConfig } from '@/lib/config' import Link from 'next/link' +import CONFIG from '../config' /** * 文字广告Banner @@ -8,13 +9,15 @@ import Link from 'next/link' */ export default function BannerItem() { // 首屏信息栏按钮文字 - const banner = siteConfig('MAGZINE_HOME_BANNER_ENABLE') - const button = siteConfig('MAGZINE_HOME_BUTTON') - const text = siteConfig('MAGZINE_HOME_BUTTON_TEXT') - const url = siteConfig('MAGZINE_HOME_BUTTON_URL') - const title = siteConfig('MAGZINE_HOME_TITLE') - const description = siteConfig('MAGZINE_HOME_DESCRIPTION') - const tips = siteConfig('MAGZINE_HOME_TIPS') + const banner = siteConfig('MAGZINE_HOME_BANNER_ENABLE', null, CONFIG) + + const button = siteConfig('MAGZINE_HOME_BUTTON', null, CONFIG) + const text = siteConfig('MAGZINE_HOME_BUTTON_TEXT', null, CONFIG) + const url = siteConfig('MAGZINE_HOME_BUTTON_URL', null, CONFIG) + const title = siteConfig('MAGZINE_HOME_TITLE', null, CONFIG) + const description = siteConfig('MAGZINE_HOME_DESCRIPTION', null, CONFIG) + const tips = siteConfig('MAGZINE_HOME_TIPS', null, CONFIG) + if (!banner) { return null } diff --git a/themes/magzine/components/CTA.js b/themes/magzine/components/CTA.js index ce5f8bd8..7458974e 100644 --- a/themes/magzine/components/CTA.js +++ b/themes/magzine/components/CTA.js @@ -12,7 +12,7 @@ export default function CTA({ notice }) { diff --git a/themes/magzine/index.js b/themes/magzine/index.js index bdfb2c72..07dcd453 100644 --- a/themes/magzine/index.js +++ b/themes/magzine/index.js @@ -62,18 +62,24 @@ const LayoutBase = props => {
+ className={`${siteConfig('FONT_STYLE')} bg-white dark:bg-hexo-black-gray w-full h-full min-h-screen flex flex-col justify-between dark:text-gray-300 scroll-smooth`}>
+ className='relative flex flex-col justify-between w-full h-full mx-auto'> {/* 主区 */} -
+
-
+ +
{children}
- {/* 行动呼吁 */} - +
@@ -115,6 +121,9 @@ const LayoutIndex = props => { {/* 文章推荐 */} + + {/* 行动呼吁 */} +
) } @@ -150,31 +159,28 @@ const LayoutSlug = props => { const { post, recommendPosts, prev, next, lock, validPassword } = props const { locale } = useGlobal() const router = useRouter() - + const waiting404 = siteConfig('POST_WAITING_TIME_FOR_404') * 1000 useEffect(() => { // 404 if (!post) { - setTimeout( - () => { - if (isBrowser) { - const article = document.querySelector( - '#article-wrapper #notion-article' - ) - if (!article) { - router.push('/404').then(() => { - console.warn('找不到页面', router.asPath) - }) - } + setTimeout(() => { + if (isBrowser) { + const article = document.querySelector( + '#article-wrapper #notion-article' + ) + if (!article) { + router.push('/404').then(() => { + console.warn('找不到页面', router.asPath) + }) } - }, - siteConfig('POST_WAITING_TIME_FOR_404') * 1000 - ) + } + }, waiting404) } }, [post]) return ( <> -
+
{/* 广告位 */} @@ -372,9 +378,11 @@ const LayoutArchive = props => { const Layout404 = props => { return ( <> -
+
404 Not found.
+ {/* 文章推荐 */} + ) } diff --git a/themes/medium/index.js b/themes/medium/index.js index dfd37ce2..cbb76614 100644 --- a/themes/medium/index.js +++ b/themes/medium/index.js @@ -191,7 +191,9 @@ const LayoutSlug = props => { setTimeout( () => { if (isBrowser) { - const article = document.querySelector('#article-wrapper #notion-article') + const article = document.querySelector( + '#article-wrapper #notion-article' + ) if (!article) { router.push('/404').then(() => { console.warn('找不到页面', router.asPath) @@ -205,7 +207,7 @@ const LayoutSlug = props => { }, [post]) return ( -
+
{/* 文章锁 */} {lock && }