From 52495e020074f2e052f64772d0f478abcce0270c Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 1 Nov 2023 18:40:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E5=88=86=E9=85=8D=E7=BD=AEsiteConfig?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Artalk.js | 3 +- components/Comment.js | 2 +- components/CommonHead.js | 40 ++++++++-------- lib/config.js | 49 ++++++++++++++++++++ lib/global.js | 5 +- lib/notion/getNotionConfig.js | 4 +- lib/notion/getNotionData.js | 4 +- pages/404.js | 5 +- pages/[prefix]/index.js | 3 +- pages/archive/index.js | 5 +- pages/category/[category]/index.js | 5 +- pages/category/[category]/page/[page].js | 5 +- pages/category/index.js | 5 +- pages/index.js | 24 +++++----- pages/page/[page].js | 5 +- pages/search/[keyword]/index.js | 5 +- pages/search/[keyword]/page/[page].js | 5 +- pages/search/index.js | 5 +- pages/tag/[tag]/index.js | 5 +- pages/tag/[tag]/page/[page].js | 5 +- pages/tag/index.js | 5 +- themes/example/components/BlogPostCard.js | 3 +- themes/example/components/Footer.js | 3 +- themes/example/components/Header.js | 5 +- themes/example/components/Title.js | 7 +-- themes/fukasawa/components/AsideLeft.js | 8 ++-- themes/fukasawa/components/Logo.js | 4 +- themes/fukasawa/components/SiteInfo.js | 3 +- themes/gitbook/components/Footer.js | 5 +- themes/gitbook/components/InfoCard.js | 6 +-- themes/gitbook/components/LogoBar.js | 6 +-- themes/heo/components/ArticleCopyright.js | 3 +- themes/heo/components/Footer.js | 4 +- themes/heo/components/InfoCard.js | 6 +-- themes/heo/components/Logo.js | 6 +-- themes/heo/components/NavBar.js | 4 +- themes/heo/components/SideBar.js | 4 +- themes/heo/index.js | 4 +- themes/hexo/components/ArticleCopyright.js | 11 +++-- themes/hexo/components/Footer.js | 4 +- themes/hexo/components/Hero.js | 3 +- themes/hexo/components/InfoCard.js | 5 +- themes/hexo/components/Logo.js | 4 +- themes/hexo/components/SideBar.js | 4 +- themes/hexo/index.js | 10 ++-- themes/matery/components/ArticleCopyright.js | 3 +- themes/matery/components/Footer.js | 4 +- themes/matery/components/Hero.js | 3 +- themes/matery/components/InfoCard.js | 6 ++- themes/matery/components/Logo.js | 4 +- themes/matery/components/SideBar.js | 8 ++-- themes/matery/index.js | 3 +- themes/medium/components/ArticleInfo.js | 5 +- themes/medium/components/Footer.js | 3 +- themes/medium/components/InfoCard.js | 5 +- themes/medium/components/LogoBar.js | 4 +- themes/medium/index.js | 5 +- themes/nav/components/Footer.js | 6 +-- themes/nav/components/InfoCard.js | 6 +-- themes/nav/components/LogoBar.js | 5 +- themes/next/components/ArticleDetail.js | 3 +- themes/next/components/Footer.js | 4 +- themes/next/components/InfoCard.js | 6 +-- themes/next/components/Logo.js | 7 +-- themes/next/index.js | 5 +- themes/nobelium/components/BlogListScroll.js | 7 +-- themes/nobelium/components/Footer.js | 3 +- themes/nobelium/components/Nav.js | 7 +-- themes/nobelium/components/Title.js | 8 ++-- themes/plog/components/BlogListScroll.js | 3 +- themes/plog/components/Footer.js | 3 +- themes/plog/components/LogoBar.js | 7 +-- themes/plog/components/Nav.js | 7 +-- themes/plog/components/SlideOvers.js | 3 +- themes/plog/components/Title.js | 8 ++-- themes/simple/components/ArticleInfo.js | 4 +- themes/simple/components/BlogItem.js | 3 +- themes/simple/components/Footer.js | 3 +- themes/simple/components/Header.js | 8 ++-- themes/simple/components/Title.js | 8 ++-- 80 files changed, 293 insertions(+), 200 deletions(-) create mode 100644 lib/config.js diff --git a/components/Artalk.js b/components/Artalk.js index 0da7734f..9f047a2f 100644 --- a/components/Artalk.js +++ b/components/Artalk.js @@ -1,4 +1,5 @@ import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import { loadExternalResource } from '@/lib/utils' // import { loadExternalResource } from '@/lib/utils' import { useEffect } from 'react' @@ -19,7 +20,7 @@ const Artalk = ({ siteInfo }) => { locale: BLOG.LANG, // pageKey: '/post/1', // 固定链接 (留空自动获取) // pageTitle: '关于引入 Artalk 的这档子事', // 页面标题 (留空自动获取) - site: siteInfo?.title // 你的站点名 + site: siteConfig('TITLE') // 你的站点名 }) }, []) return ( diff --git a/components/Comment.js b/components/Comment.js index 6be4bc64..9359ed36 100644 --- a/components/Comment.js +++ b/components/Comment.js @@ -86,7 +86,7 @@ const Comment = ({ siteInfo, frontMatter, className }) => {
{BLOG.COMMENT_ARTALK_SERVER && (
- +
)} {BLOG.COMMENT_TWIKOO_ENV_ID && (
diff --git a/components/CommonHead.js b/components/CommonHead.js index 24bfae69..752a65bf 100644 --- a/components/CommonHead.js +++ b/components/CommonHead.js @@ -1,34 +1,34 @@ -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import Head from 'next/head' const CommonHead = ({ meta, children }) => { - let url = BLOG?.PATH?.length ? `${BLOG.LINK}/${BLOG.SUB_PATH}` : BLOG.LINK + let url = siteConfig('PATH')?.length ? `${siteConfig('LINK')}/${siteConfig('SUB_PATH')}` : siteConfig('LINK') let image if (meta) { url = `${url}/${meta.slug}` image = meta.image || '/bg_image.jpg' } - const title = meta?.title || BLOG.TITLE - const description = meta?.description || BLOG.DESCRIPTION + const title = meta?.title || siteConfig('TITLE') + const description = meta?.description || siteConfig('DESCRIPTION') const type = meta?.type || 'website' - const keywords = meta?.tags || BLOG.KEYWORDS - const lang = BLOG.LANG.replace('-', '_') // Facebook OpenGraph 要 zh_CN 這樣的格式才抓得到語言 - const category = meta?.category || BLOG.KEYWORDS || '軟體科技' // section 主要是像是 category 這樣的分類,Facebook 用這個來抓連結的分類 + const keywords = meta?.tags || siteConfig('KEYWORDS') + const lang = siteConfig('LANG').replace('-', '_') // Facebook OpenGraph 要 zh_CN 這樣的格式才抓得到語言 + const category = meta?.category || siteConfig('KEYWORDS') || '軟體科技' // section 主要是像是 category 這樣的分類,Facebook 用這個來抓連結的分類 return ( {title} - + - {BLOG.SEO_GOOGLE_SITE_VERIFICATION && ( + {siteConfig('SEO_GOOGLE_SITE_VERIFICATION') && ( )} - {BLOG.SEO_BAIDU_SITE_VERIFICATION && ()} + {siteConfig('SEO_BAIDU_SITE_VERIFICATION') && ()} @@ -36,33 +36,33 @@ const CommonHead = ({ meta, children }) => { - + - {BLOG.COMMENT_WEBMENTION.ENABLE && ( + {siteConfig('COMMENT_WEBMENTION').ENABLE && ( <> - - + + )} - {BLOG.COMMENT_WEBMENTION.ENABLE && BLOG.COMMENT_WEBMENTION.AUTH !== '' && ( - + {siteConfig('COMMENT_WEBMENTION').ENABLE && siteConfig('COMMENT_WEBMENTION').AUTH !== '' && ( + )} - {JSON.parse(BLOG.ANALYTICS_BUSUANZI_ENABLE) && } + {JSON.parse(siteConfig('ANALYTICS_BUSUANZI_ENABLE')) && } {meta?.type === 'Post' && ( <> - + - + )} {children} diff --git a/lib/config.js b/lib/config.js new file mode 100644 index 00000000..62b5149b --- /dev/null +++ b/lib/config.js @@ -0,0 +1,49 @@ +'use client' + +import BLOG from '@/blog.config' +import { useGlobal } from './global' + +/** + * 读取配置 + * @param {*} key + * @returns + */ +export const siteConfig = (key) => { + let global = null + try { + // eslint-disable-next-line react-hooks/rules-of-hooks + global = useGlobal() + } catch (error) {} + + // 首先 配置最优先读取NOTION中的表格配置 + let val = null + let siteInfo = null + + if (global) { + val = global.NOTION_CONFIG?.[key] + siteInfo = global.siteInfo + console.log('当前变量', key, val) + } + + if (!val) { + // 这里针对部分key做一些兼容处理 + switch (key) { + case 'HOME_BANNER_IMAGE': + val = siteInfo?.pageCover // 封面图取Notion的封面 + break + case 'AVATAR': + val = siteInfo?.icon // 封面图取Notion的封面 + break + case 'TITLE': + val = siteConfig('TITLE') // 标题取Notion中的标题 + break + } + } + + // 其次 NOTION没有找到配置,则会读取blog.config.js文件 + if (!val) { + val = BLOG[key] + } + console.log('配置', key, val) + return val +} diff --git a/lib/global.js b/lib/global.js index c290a9e0..d1fc4142 100644 --- a/lib/global.js +++ b/lib/global.js @@ -1,10 +1,10 @@ import { generateLocaleDict, initLocale } from './lang' import { createContext, useContext, useEffect, useState } from 'react' import { useRouter } from 'next/router' -import BLOG from '@/blog.config' import { THEMES, initDarkMode } from '@/themes/theme' import NProgress from 'nprogress' import { getQueryVariable, isBrowser } from './utils' +import BLOG from '@/blog.config' const GlobalContext = createContext() @@ -15,7 +15,7 @@ const GlobalContext = createContext() * @constructor */ export function GlobalContextProvider(props) { - const { children, siteInfo, categoryOptions, tagOptions } = props + const { children, siteInfo, categoryOptions, tagOptions, NOTION_CONFIG } = props const router = useRouter() const [lang, updateLang] = useState(BLOG.LANG) // 默认语言 const [locale, updateLocale] = useState(generateLocaleDict(BLOG.LANG)) // 默认语言 @@ -68,6 +68,7 @@ export function GlobalContextProvider(props) { return ( { - const { siteInfo } = useGlobal() - const meta = { title: `${props?.siteInfo?.title} | 页面找不到啦`, image: siteInfo?.pageCover } + const meta = { title: `${siteConfig('TITLE')} | 页面找不到啦`, image: siteConfig('HOME_BANNER_IMAGE') } props = { ...props, meta } diff --git a/pages/[prefix]/index.js b/pages/[prefix]/index.js index 6fa5d47b..b350fb18 100644 --- a/pages/[prefix]/index.js +++ b/pages/[prefix]/index.js @@ -10,6 +10,7 @@ import { getLayoutByTheme } from '@/themes/theme' import md5 from 'js-md5' import { isBrowser } from '@/lib/utils' import { uploadDataToAlgolia } from '@/lib/algolia' +import { siteConfig } from '@/lib/config' /** * 根据notion的slug访问页面 @@ -66,7 +67,7 @@ const Slug = props => { }, [post]) const meta = { - title: post ? `${post?.title} | ${siteInfo?.title}` : `${props?.siteInfo?.title || BLOG.TITLE} | loading`, + title: post ? `${post?.title} | ${siteConfig('TITLE')}` : `${props?.siteConfig('TITLE') || BLOG.TITLE} | loading`, description: post?.summary, type: post?.type, slug: post?.slug, diff --git a/pages/archive/index.js b/pages/archive/index.js index 106ad7d2..3726291d 100644 --- a/pages/archive/index.js +++ b/pages/archive/index.js @@ -6,6 +6,7 @@ import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' import { isBrowser } from '@/lib/utils' import { formatDateFmt } from '@/lib/formatDate' +import { siteConfig } from '@/lib/config' const ArchiveIndex = props => { const { siteInfo } = props @@ -29,8 +30,8 @@ const ArchiveIndex = props => { }, []) const meta = { - title: `${locale.NAV.ARCHIVE} | ${siteInfo?.title}`, - description: siteInfo?.description, + title: `${locale.NAV.ARCHIVE} | ${siteConfig('TITLE')}`, + description: siteConfig('HOME_BANNER_IMAGE'), image: siteInfo?.pageCover, slug: 'archive', type: 'website' diff --git a/pages/category/[category]/index.js b/pages/category/[category]/index.js index 03cd4fbd..a2c30722 100644 --- a/pages/category/[category]/index.js +++ b/pages/category/[category]/index.js @@ -4,6 +4,7 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' /** * 分类页 @@ -19,9 +20,9 @@ export default function Category(props) { const meta = { title: `${props.category} | ${locale.COMMON.CATEGORY} | ${ - siteInfo?.title || '' + siteConfig('TITLE') || '' }`, - description: siteInfo?.description, + description: siteConfig('HOME_BANNER_IMAGE'), slug: 'category/' + props.category, image: siteInfo?.pageCover, type: 'website' diff --git a/pages/category/[category]/page/[page].js b/pages/category/[category]/page/[page].js index 9174e117..8a6cccc8 100644 --- a/pages/category/[category]/page/[page].js +++ b/pages/category/[category]/page/[page].js @@ -4,6 +4,7 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' /** * 分类页 @@ -19,9 +20,9 @@ export default function Category(props) { const meta = { title: `${props.category} | ${locale.COMMON.CATEGORY} | ${ - siteInfo?.title || '' + siteConfig('TITLE') || '' }`, - description: siteInfo?.description, + description: siteConfig('HOME_BANNER_IMAGE'), slug: 'category/' + props.category, image: siteInfo?.pageCover, type: 'website' diff --git a/pages/category/index.js b/pages/category/index.js index b4872000..8f6d98bc 100644 --- a/pages/category/index.js +++ b/pages/category/index.js @@ -4,6 +4,7 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' /** * 分类首页 @@ -18,8 +19,8 @@ export default function Category(props) { const Layout = getLayoutByTheme(useRouter()) const meta = { - title: `${locale.COMMON.CATEGORY} | ${siteInfo?.title}`, - description: siteInfo?.description, + title: `${locale.COMMON.CATEGORY} | ${siteConfig('TITLE')}`, + description: siteConfig('HOME_BANNER_IMAGE'), image: siteInfo?.pageCover, slug: 'category', type: 'website' diff --git a/pages/index.js b/pages/index.js index 328ece1e..ac72c1b5 100644 --- a/pages/index.js +++ b/pages/index.js @@ -5,6 +5,7 @@ import { generateRss } from '@/lib/rss' import { generateRobotsTxt } from '@/lib/robots.txt' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' /** * 首页布局 @@ -14,7 +15,15 @@ import { getLayoutByTheme } from '@/themes/theme' const Index = props => { // 根据页面路径加载不同Layout文件 const Layout = getLayoutByTheme(useRouter()) - return + + const meta = { + title: `${siteConfig('TITLE')} | ${siteConfig('BIO')}`, + description: siteConfig('DESCRIPTION'), + image: siteConfig('HOME_BANNER_IMAGE'), + slug: '', + type: 'website' + } + return } /** @@ -25,16 +34,8 @@ export async function getStaticProps() { const from = 'index' const props = await getGlobalData({ from }) - const { siteInfo } = props props.posts = props.allPages?.filter(page => page.type === 'Post' && page.status === 'Published') - const meta = { - title: `${siteInfo?.title} | ${siteInfo?.description}`, - description: siteInfo?.description, - image: siteInfo?.pageCover, - slug: '', - type: 'website' - } // 处理分页 if (BLOG.POST_LIST_STYLE === 'scroll') { // 滚动列表默认给前端返回所有数据 @@ -65,10 +66,7 @@ export async function getStaticProps() { delete props.allPages return { - props: { - meta, - ...props - }, + props, revalidate: parseInt(BLOG.NEXT_REVALIDATE_SECOND) } } diff --git a/pages/page/[page].js b/pages/page/[page].js index 02b847a8..131feb45 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -3,6 +3,7 @@ import { getPostBlocks } from '@/lib/notion' import { getGlobalData } from '@/lib/notion/getNotionData' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' /** * 文章列表分页 @@ -16,8 +17,8 @@ const Page = props => { const Layout = getLayoutByTheme(useRouter()) const meta = { - title: `${props?.page} | Page | ${siteInfo?.title}`, - description: siteInfo?.description, + title: `${props?.page} | Page | ${siteConfig('TITLE')}`, + description: siteConfig('HOME_BANNER_IMAGE'), image: siteInfo?.pageCover, slug: 'page/' + props.page, type: 'website' diff --git a/pages/search/[keyword]/index.js b/pages/search/[keyword]/index.js index 042bbf85..bc2514a1 100644 --- a/pages/search/[keyword]/index.js +++ b/pages/search/[keyword]/index.js @@ -4,6 +4,7 @@ import { getDataFromCache } from '@/lib/cache/cache_manager' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' const Index = props => { const { keyword, siteInfo } = props @@ -13,8 +14,8 @@ const Index = props => { const Layout = getLayoutByTheme(useRouter()) const meta = { - title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteInfo?.title}`, - description: siteInfo?.title, + title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteConfig('TITLE')}`, + description: siteConfig('TITLE'), image: siteInfo?.pageCover, slug: 'search/' + (keyword || ''), type: 'website' diff --git a/pages/search/[keyword]/page/[page].js b/pages/search/[keyword]/page/[page].js index 20240f19..c5c4aeb8 100644 --- a/pages/search/[keyword]/page/[page].js +++ b/pages/search/[keyword]/page/[page].js @@ -4,6 +4,7 @@ import { getDataFromCache } from '@/lib/cache/cache_manager' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' const Index = props => { const { keyword, siteInfo } = props @@ -13,8 +14,8 @@ const Index = props => { const Layout = getLayoutByTheme(useRouter()) const meta = { - title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteInfo?.title}`, - description: siteInfo?.title, + title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteConfig('TITLE')}`, + description: siteConfig('TITLE'), image: siteInfo?.pageCover, slug: 'search/' + (keyword || ''), type: 'website' diff --git a/pages/search/index.js b/pages/search/index.js index 22061cbd..31d09af3 100644 --- a/pages/search/index.js +++ b/pages/search/index.js @@ -3,6 +3,7 @@ import { useGlobal } from '@/lib/global' import { useRouter } from 'next/router' import BLOG from '@/blog.config' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' /** * 搜索路由 @@ -34,8 +35,8 @@ const Search = props => { } const meta = { - title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteInfo?.title}`, - description: siteInfo?.description, + title: `${keyword || ''}${keyword ? ' | ' : ''}${locale.NAV.SEARCH} | ${siteConfig('TITLE')}`, + description: siteConfig('HOME_BANNER_IMAGE'), image: siteInfo?.pageCover, slug: 'search', type: 'website' diff --git a/pages/tag/[tag]/index.js b/pages/tag/[tag]/index.js index bd9f7529..f12cdc41 100644 --- a/pages/tag/[tag]/index.js +++ b/pages/tag/[tag]/index.js @@ -3,6 +3,7 @@ import { getGlobalData } from '@/lib/notion/getNotionData' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' /** * 标签下的文章列表 @@ -17,8 +18,8 @@ const Tag = props => { const Layout = getLayoutByTheme(useRouter()) const meta = { - title: `${tag} | ${locale.COMMON.TAGS} | ${siteInfo?.title}`, - description: siteInfo?.description, + title: `${tag} | ${locale.COMMON.TAGS} | ${siteConfig('TITLE')}`, + description: siteConfig('HOME_BANNER_IMAGE'), image: siteInfo?.pageCover, slug: 'tag/' + tag, type: 'website' diff --git a/pages/tag/[tag]/page/[page].js b/pages/tag/[tag]/page/[page].js index 2eaef518..c708793b 100644 --- a/pages/tag/[tag]/page/[page].js +++ b/pages/tag/[tag]/page/[page].js @@ -3,6 +3,7 @@ import { getGlobalData } from '@/lib/notion/getNotionData' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' const Tag = props => { const { locale } = useGlobal() @@ -12,8 +13,8 @@ const Tag = props => { const Layout = getLayoutByTheme(useRouter()) const meta = { - title: `${tag} | ${locale.COMMON.TAGS} | ${siteInfo?.title}`, - description: siteInfo?.description, + title: `${tag} | ${locale.COMMON.TAGS} | ${siteConfig('TITLE')}`, + description: siteConfig('HOME_BANNER_IMAGE'), image: siteInfo?.pageCover, slug: 'tag/' + tag, type: 'website' diff --git a/pages/tag/index.js b/pages/tag/index.js index 54dab9a4..cb6db4da 100644 --- a/pages/tag/index.js +++ b/pages/tag/index.js @@ -3,6 +3,7 @@ import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import { useRouter } from 'next/router' import { getLayoutByTheme } from '@/themes/theme' +import { siteConfig } from '@/lib/config' /** * 标签首页 @@ -17,8 +18,8 @@ const TagIndex = props => { const Layout = getLayoutByTheme(useRouter()) const meta = { - title: `${locale.COMMON.TAGS} | ${siteInfo?.title}`, - description: siteInfo?.description, + title: `${locale.COMMON.TAGS} | ${siteConfig('TITLE')}`, + description: siteConfig('HOME_BANNER_IMAGE'), image: siteInfo?.pageCover, slug: 'tag', type: 'website' diff --git a/themes/example/components/BlogPostCard.js b/themes/example/components/BlogPostCard.js index faf1753d..fb91a307 100644 --- a/themes/example/components/BlogPostCard.js +++ b/themes/example/components/BlogPostCard.js @@ -3,6 +3,7 @@ import CONFIG from '../config' import Link from 'next/link' import TwikooCommentCount from '@/components/TwikooCommentCount' import LazyImage from '@/components/LazyImage' +import { siteConfig } from '@/lib/config' const BlogPostCard = ({ post }) => { const showPageCover = CONFIG.POST_LIST_COVER && post?.pageCoverThumbnail @@ -18,7 +19,7 @@ const BlogPostCard = ({ post }) => {
- by {BLOG.AUTHOR} on {post.date?.start_date || post.createdTime} + by {siteConfig('AUTHOR')} on {post.date?.start_date || post.createdTime} | {post.category} diff --git a/themes/example/components/Footer.js b/themes/example/components/Footer.js index 09af18fe..26c1ae74 100644 --- a/themes/example/components/Footer.js +++ b/themes/example/components/Footer.js @@ -1,5 +1,6 @@ import BLOG from '@/blog.config' import DarkModeButton from '@/components/DarkModeButton' +import { siteConfig } from '@/lib/config' export const Footer = (props) => { const d = new Date() @@ -15,7 +16,7 @@ export const Footer = (props) => {
-
©{`${copyrightDate}`} {BLOG.AUTHOR}. All rights reserved.
+
©{`${copyrightDate}`} {siteConfig('AUTHOR')}. All rights reserved.
{/* 右侧链接 */} {/* Privacy Policy */} diff --git a/themes/example/components/Header.js b/themes/example/components/Header.js index 0cd85268..2ec1e27b 100644 --- a/themes/example/components/Header.js +++ b/themes/example/components/Header.js @@ -1,12 +1,11 @@ import Link from 'next/link' +import { siteConfig } from '@/lib/config' /** * 网站顶部 * @returns */ export const Header = (props) => { - const { siteInfo } = props - return (
@@ -14,7 +13,7 @@ export const Header = (props) => { href='/' className="py-6 w-full text-center md:text-left md:w-auto text-gray-dark no-underline flex justify-center items-center"> - {siteInfo?.title} + {siteConfig('TITLE')}
{/* 右侧文字 */} diff --git a/themes/example/components/Title.js b/themes/example/components/Title.js index e57e2347..08fd67f1 100644 --- a/themes/example/components/Title.js +++ b/themes/example/components/Title.js @@ -1,4 +1,5 @@ import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' /** * 标题栏 @@ -6,9 +7,9 @@ import BLOG from '@/blog.config' * @returns */ export const Title = (props) => { - const { siteInfo, post } = props - const title = post?.title || siteInfo?.description - const description = post?.description || BLOG.AUTHOR + const { post } = props + const title = post?.title || siteConfig('HOME_BANNER_IMAGE') + const description = post?.description || siteConfig('AUTHOR') return

{title}

diff --git a/themes/fukasawa/components/AsideLeft.js b/themes/fukasawa/components/AsideLeft.js index bf6edb45..131e5f31 100644 --- a/themes/fukasawa/components/AsideLeft.js +++ b/themes/fukasawa/components/AsideLeft.js @@ -12,9 +12,7 @@ import SocialButton from './SocialButton' import { useFukasawaGlobal } from '..' import CONFIG from '@/themes/fukasawa/config' import { AdSlot } from '@/components/GoogleAdsense' - -// import { debounce } from 'lodash' -// import { useEffect } from 'react' +import { siteConfig } from '@/lib/config' /** * 侧边栏 @@ -22,7 +20,7 @@ import { AdSlot } from '@/components/GoogleAdsense' * @returns */ function AsideLeft(props) { - const { tagOptions, currentTag, categoryOptions, currentCategory, post, slot, siteInfo, notice } = props + const { tagOptions, currentTag, categoryOptions, currentCategory, post, slot, notice } = props const router = useRouter() const { isCollapsed, setIsCollapse } = useFukasawaGlobal() // 折叠侧边栏 @@ -65,7 +63,7 @@ function AsideLeft(props) {
- {siteInfo?.description} + {siteConfig('HOME_BANNER_IMAGE')}
diff --git a/themes/fukasawa/components/Logo.js b/themes/fukasawa/components/Logo.js index 3b6720fb..1b28e1ec 100644 --- a/themes/fukasawa/components/Logo.js +++ b/themes/fukasawa/components/Logo.js @@ -1,13 +1,13 @@ import Link from 'next/link' +import { siteConfig } from '@/lib/config' const Logo = props => { - const { siteInfo } = props return (
- {siteInfo?.title} + {siteConfig('TITLE')}
); diff --git a/themes/fukasawa/components/SiteInfo.js b/themes/fukasawa/components/SiteInfo.js index 3a18bcd1..d4b25b54 100644 --- a/themes/fukasawa/components/SiteInfo.js +++ b/themes/fukasawa/components/SiteInfo.js @@ -1,4 +1,5 @@ import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' function SiteInfo ({ title }) { const d = new Date() @@ -14,7 +15,7 @@ function SiteInfo ({ title }) {
- © {`${copyrightDate}`} {BLOG.AUTHOR}.
+ © {`${copyrightDate}`} {siteConfig('AUTHOR')}.
{BLOG.BEI_AN && <> {BLOG.BEI_AN}
} diff --git a/themes/gitbook/components/Footer.js b/themes/gitbook/components/Footer.js index fb1d339c..09cb9daf 100644 --- a/themes/gitbook/components/Footer.js +++ b/themes/gitbook/components/Footer.js @@ -1,5 +1,6 @@ import React from 'react' import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' const Footer = ({ siteInfo }) => { const d = new Date() @@ -18,7 +19,7 @@ const Footer = ({ siteInfo }) => {
- + © {`${copyrightDate}`}
@@ -30,7 +31,7 @@ const Footer = ({ siteInfo }) => {
-

{siteInfo?.title}

+

{siteConfig('TITLE')}

) diff --git a/themes/gitbook/components/InfoCard.js b/themes/gitbook/components/InfoCard.js index 13fe31c8..6687aa04 100644 --- a/themes/gitbook/components/InfoCard.js +++ b/themes/gitbook/components/InfoCard.js @@ -1,17 +1,17 @@ import BLOG from '@/blog.config' import LazyImage from '@/components/LazyImage' import Router from 'next/router' -import React from 'react' import SocialButton from './SocialButton' +import { siteConfig } from '@/lib/config' const InfoCard = (props) => { const { siteInfo } = props return
{ Router.push('/about') }}> - +
-
{BLOG.AUTHOR}
+
{siteConfig('AUTHOR')}
{BLOG.BIO}
diff --git a/themes/gitbook/components/LogoBar.js b/themes/gitbook/components/LogoBar.js index 70c96b46..e0f7b4cb 100644 --- a/themes/gitbook/components/LogoBar.js +++ b/themes/gitbook/components/LogoBar.js @@ -1,7 +1,7 @@ -import BLOG from '@/blog.config' import LazyImage from '@/components/LazyImage' import { useGitBookGlobal } from '@/themes/gitbook' import Link from 'next/link' +import { siteConfig } from '@/lib/config' /** * Logo区域 @@ -21,8 +21,8 @@ export default function LogoBar(props) {
- - {siteInfo?.title} + + {siteConfig('TITLE')}
) diff --git a/themes/heo/components/ArticleCopyright.js b/themes/heo/components/ArticleCopyright.js index 78500ddf..740fdc1c 100644 --- a/themes/heo/components/ArticleCopyright.js +++ b/themes/heo/components/ArticleCopyright.js @@ -4,6 +4,7 @@ import Link from 'next/link' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import CONFIG from '../config' +import { siteConfig } from '@/lib/config' export default function ArticleCopyright () { const router = useRouter() @@ -24,7 +25,7 @@ export default function ArticleCopyright () {
  • {locale.COMMON.AUTHOR}: - {BLOG.AUTHOR} + {siteConfig('AUTHOR')}
  • diff --git a/themes/heo/components/Footer.js b/themes/heo/components/Footer.js index 772ade19..4899a544 100644 --- a/themes/heo/components/Footer.js +++ b/themes/heo/components/Footer.js @@ -1,7 +1,7 @@ import React from 'react' import BLOG from '@/blog.config' import SocialButton from './SocialButton' -// import DarkModeButton from '@/components/DarkModeButton' +import { siteConfig } from '@/lib/config' const Footer = ({ title }) => { const d = new Date() @@ -34,7 +34,7 @@ const Footer = ({ title }) => { {/* 页脚 */} -
    +
  • ) } diff --git a/themes/nobelium/components/BlogListScroll.js b/themes/nobelium/components/BlogListScroll.js index d3d91abb..90d1d0e1 100644 --- a/themes/nobelium/components/BlogListScroll.js +++ b/themes/nobelium/components/BlogListScroll.js @@ -1,9 +1,10 @@ import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import Link from 'next/link' -import React from 'react' import throttle from 'lodash.throttle' import { deepClone } from '@/lib/utils' +import { siteConfig } from '@/lib/config' +import { useEffect } from 'react' export const BlogListScroll = props => { const { posts } = props @@ -36,7 +37,7 @@ export const BlogListScroll = props => { } }, 500)) - React.useEffect(() => { + useEffect(() => { window.addEventListener('scroll', scrollTrigger) return () => { @@ -57,7 +58,7 @@ export const BlogListScroll = props => {
    - by {BLOG.AUTHOR} on {p.date?.start_date || p.createdTime} + by {siteConfig('AUTHOR')} on {p.date?.start_date || p.createdTime} | {p.category} | diff --git a/themes/nobelium/components/Footer.js b/themes/nobelium/components/Footer.js index 6b4b7857..3b4044a8 100644 --- a/themes/nobelium/components/Footer.js +++ b/themes/nobelium/components/Footer.js @@ -1,6 +1,7 @@ import BLOG from '@/blog.config' import DarkModeButton from '@/components/DarkModeButton' import Vercel from '@/components/Vercel' +import { siteConfig } from '@/lib/config' export const Footer = (props) => { const d = new Date() @@ -25,7 +26,7 @@ export const Footer = (props) => {

    - © {BLOG.AUTHOR} {copyrightDate} + © {siteConfig('AUTHOR')} {copyrightDate}

    diff --git a/themes/nobelium/components/Nav.js b/themes/nobelium/components/Nav.js index 7e6c12ac..73df49a3 100644 --- a/themes/nobelium/components/Nav.js +++ b/themes/nobelium/components/Nav.js @@ -10,6 +10,7 @@ import { MenuItemCollapse } from './MenuItemCollapse' import LazyImage from '@/components/LazyImage' import RandomPostButton from './RandomPostButton' import SearchButton from './SearchButton' +import { siteConfig } from '@/lib/config' const Nav = props => { const { navBarTitle, fullWidth, siteInfo } = props @@ -48,7 +49,7 @@ const Nav = props => {
    {/* */} {CONFIG.NAV_NOTION_ICON - ? + ? : }
    @@ -62,8 +63,8 @@ const Nav = props => { ) : (

    - {siteInfo?.title} - {/* ,{' '}{siteInfo?.description} */} + {siteConfig('TITLE')} + {/* ,{' '}{siteConfig('HOME_BANNER_IMAGE')} */}

    )}
    diff --git a/themes/nobelium/components/Title.js b/themes/nobelium/components/Title.js index e57e2347..a1512af2 100644 --- a/themes/nobelium/components/Title.js +++ b/themes/nobelium/components/Title.js @@ -1,4 +1,4 @@ -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' /** * 标题栏 @@ -6,9 +6,9 @@ import BLOG from '@/blog.config' * @returns */ export const Title = (props) => { - const { siteInfo, post } = props - const title = post?.title || siteInfo?.description - const description = post?.description || BLOG.AUTHOR + const { post } = props + const title = post?.title || siteConfig('HOME_BANNER_IMAGE') + const description = post?.description || siteConfig('AUTHOR') return

    {title}

    diff --git a/themes/plog/components/BlogListScroll.js b/themes/plog/components/BlogListScroll.js index 157e80e4..809451f6 100644 --- a/themes/plog/components/BlogListScroll.js +++ b/themes/plog/components/BlogListScroll.js @@ -3,6 +3,7 @@ import { useGlobal } from '@/lib/global' import Link from 'next/link' import React from 'react' import throttle from 'lodash.throttle' +import { siteConfig } from '@/lib/config' export const BlogListScroll = props => { const { posts } = props @@ -56,7 +57,7 @@ export const BlogListScroll = props => {
    - by {BLOG.AUTHOR} on {p.date?.start_date || p.createdTime} + by {siteConfig('AUTHOR')} on {p.date?.start_date || p.createdTime} | {p.category} | diff --git a/themes/plog/components/Footer.js b/themes/plog/components/Footer.js index 2a6bdcb9..d53de2f3 100644 --- a/themes/plog/components/Footer.js +++ b/themes/plog/components/Footer.js @@ -1,5 +1,6 @@ import BLOG from '@/blog.config' import Vercel from '@/components/Vercel' +import { siteConfig } from '@/lib/config' export const Footer = (props) => { const d = new Date() @@ -15,7 +16,7 @@ export const Footer = (props) => { return
    -
    © {BLOG.AUTHOR} {copyrightDate}
    +
    © {siteConfig('AUTHOR')} {copyrightDate}
    diff --git a/themes/plog/components/LogoBar.js b/themes/plog/components/LogoBar.js index 07539f2f..070b45ae 100644 --- a/themes/plog/components/LogoBar.js +++ b/themes/plog/components/LogoBar.js @@ -3,6 +3,7 @@ import LazyImage from '@/components/LazyImage' import Link from 'next/link' import CONFIG from '../config' import { SvgIcon } from './SvgIcon' +import { siteConfig } from '@/lib/config' /** * logo文字栏 @@ -16,7 +17,7 @@ export default function LogoBar(props) {
    {CONFIG.NAV_NOTION_ICON - ? + ? : }
    @@ -30,8 +31,8 @@ export default function LogoBar(props) { ) : (

    - {siteInfo?.title} - {' '}{siteInfo?.description} + {siteConfig('TITLE')} + {' '}{siteConfig('HOME_BANNER_IMAGE')}

    )}
    diff --git a/themes/plog/components/Nav.js b/themes/plog/components/Nav.js index 401f0d49..f57accac 100644 --- a/themes/plog/components/Nav.js +++ b/themes/plog/components/Nav.js @@ -8,11 +8,12 @@ import { MenuItemDrop } from './MenuItemDrop' import Collapse from '@/components/Collapse' import { MenuItemCollapse } from './MenuItemCollapse' import LazyImage from '@/components/LazyImage' +import { siteConfig } from '@/lib/config' const Header = props => { const { fullWidth, siteInfo } = props - const title = siteInfo?.title + const title = siteConfig('TITLE') return
    ) diff --git a/themes/simple/components/Title.js b/themes/simple/components/Title.js index e57e2347..a1512af2 100644 --- a/themes/simple/components/Title.js +++ b/themes/simple/components/Title.js @@ -1,4 +1,4 @@ -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' /** * 标题栏 @@ -6,9 +6,9 @@ import BLOG from '@/blog.config' * @returns */ export const Title = (props) => { - const { siteInfo, post } = props - const title = post?.title || siteInfo?.description - const description = post?.description || BLOG.AUTHOR + const { post } = props + const title = post?.title || siteConfig('HOME_BANNER_IMAGE') + const description = post?.description || siteConfig('AUTHOR') return

    {title}