diff --git a/blog.config.js b/blog.config.js index ae020dac..80b8ddbd 100644 --- a/blog.config.js +++ b/blog.config.js @@ -5,7 +5,7 @@ const BLOG = { process.env.NOTION_PAGE_ID || '02ab3b8678004aa69e9e415905ef32a5', PSEUDO_STATIC: process.env.NEXT_PUBLIC_PSEUDO_STATIC || false, // 伪静态路径,开启后所有文章URL都以 .html 结尾。 NEXT_REVALIDATE_SECOND: process.env.NEXT_PUBLIC_REVALIDATE_SECOND || 5, // 更新内容缓存间隔 单位(秒);即每个页面有5秒的纯静态期、此期间无论多少次访问都不会抓取notion数据;调大该值有助于节省Vercel资源、同时提升访问速率,但也会使文章更新有延迟。 - THEME: process.env.NEXT_PUBLIC_THEME || 'hexo', // 当前主题,在themes文件夹下可找到所有支持的主题;主题名称就是文件夹名,例如 example,fukasawa,gitbook,heo,hexo,landing,matery,medium,next,nobelium,plog,simple + THEME: process.env.NEXT_PUBLIC_THEME || 'simple', // 当前主题,在themes文件夹下可找到所有支持的主题;主题名称就是文件夹名,例如 example,fukasawa,gitbook,heo,hexo,landing,matery,medium,next,nobelium,plog,simple THEME_SWITCH: process.env.NEXT_PUBLIC_THEME_SWITCH || false, // 是否显示切换主题按钮 LANG: process.env.NEXT_PUBLIC_LANG || 'zh-CN', // e.g 'zh-CN','en-US' see /lib/lang.js for more. SINCE: 2021, // e.g if leave this empty, current year will be used. diff --git a/lib/notion/getNotionConfig.js b/lib/notion/getNotionConfig.js index e87f8378..ef319105 100644 --- a/lib/notion/getNotionConfig.js +++ b/lib/notion/getNotionConfig.js @@ -21,7 +21,7 @@ export async function getConfigMapFromConfigPage(allPages) { const notionConfig = BLOG if (!allPages || !Array.isArray(allPages) || allPages.length === 0) { - console.warn('[Notion配置] 忽略的配置', allPages, typeof allPages) + console.warn('[Notion配置] 忽略的配置') return null } const configPage = allPages?.find(post => { @@ -29,7 +29,7 @@ export async function getConfigMapFromConfigPage(allPages) { }) if (!configPage) { - console.warn('[Notion配置]未找到配置页面', allPages, typeof allPages) + console.warn('[Notion配置] 未找到配置页面') return null } const configPageId = configPage.id @@ -40,7 +40,7 @@ export async function getConfigMapFromConfigPage(allPages) { const content = pageRecordMap.block[configPageId].value.content if (!content) { - console.warn('[Notion配置]未找到配置表格', pageRecordMap.block[configPageId], pageRecordMap.block[configPageId].value) + console.warn('[Notion配置] 未找到配置表格', pageRecordMap.block[configPageId], pageRecordMap.block[configPageId].value) return null } diff --git a/themes/commerce/components/ArticleCopyright.js b/themes/commerce/components/ArticleCopyright.js index 9cf537a1..67c65bab 100644 --- a/themes/commerce/components/ArticleCopyright.js +++ b/themes/commerce/components/ArticleCopyright.js @@ -1,4 +1,3 @@ -import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import Link from 'next/link' import { useRouter } from 'next/router' @@ -8,7 +7,7 @@ import { siteConfig } from '@/lib/config' export default function ArticleCopyright () { const router = useRouter() - const [path, setPath] = useState(BLOG.LINK + router.asPath) + const [path, setPath] = useState(siteConfig('LINK') + router.asPath) useEffect(() => { setPath(window.location.href) }) diff --git a/themes/commerce/components/ArticleRecommend.js b/themes/commerce/components/ArticleRecommend.js index dc5ef58e..0feff96d 100644 --- a/themes/commerce/components/ArticleRecommend.js +++ b/themes/commerce/components/ArticleRecommend.js @@ -1,6 +1,6 @@ import Link from 'next/link' import CONFIG from '../config' -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import LazyImage from '@/components/LazyImage' @@ -38,7 +38,7 @@ export default function ArticleRecommend({ recommendPosts, siteInfo }) { ( diff --git a/themes/commerce/components/BlogPostArchive.js b/themes/commerce/components/BlogPostArchive.js index 7de25e1a..860e8c6a 100644 --- a/themes/commerce/components/BlogPostArchive.js +++ b/themes/commerce/components/BlogPostArchive.js @@ -1,5 +1,6 @@ import Link from 'next/link' -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' + /** * 博客归档列表 * @param posts 所有文章 @@ -29,7 +30,7 @@ const BlogPostArchive = ({ posts = [], archiveTitle }) => { {post.date?.start_date}{' '}   diff --git a/themes/commerce/components/BlogPostCardInfo.js b/themes/commerce/components/BlogPostCardInfo.js index eb2b5676..23dd2ad2 100644 --- a/themes/commerce/components/BlogPostCardInfo.js +++ b/themes/commerce/components/BlogPostCardInfo.js @@ -2,7 +2,7 @@ import NotionPage from '@/components/NotionPage' import Link from 'next/link' import TagItemMini from './TagItemMini' import TwikooCommentCount from '@/components/TwikooCommentCount' -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import { formatDateFmt } from '@/lib/formatDate' /** @@ -15,7 +15,7 @@ export const BlogPostCardInfo = ({ post, showPreview, showPageCover, showSummary
{/* 标题 */} diff --git a/themes/commerce/components/BlogPostListPage.js b/themes/commerce/components/BlogPostListPage.js index 3f4583c3..17ca53bb 100644 --- a/themes/commerce/components/BlogPostListPage.js +++ b/themes/commerce/components/BlogPostListPage.js @@ -1,6 +1,6 @@ import ProductCard from './ProductCard' import PaginationNumber from './PaginationNumber' -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import BlogPostListEmpty from './BlogPostListEmpty' /** @@ -12,8 +12,8 @@ import BlogPostListEmpty from './BlogPostListEmpty' * @constructor */ const BlogPostListPage = ({ page = 1, posts = [], postCount, siteInfo }) => { - const totalPage = Math.ceil(postCount / BLOG.POSTS_PER_PAGE) - const showPagination = postCount >= BLOG.POSTS_PER_PAGE + const totalPage = Math.ceil(postCount / parseInt(siteConfig('POSTS_PER_PAGE'))) + const showPagination = postCount >= parseInt(siteConfig('POSTS_PER_PAGE')) if (!posts || posts.length === 0 || page > totalPage) { return } else { diff --git a/themes/commerce/components/BlogPostListScroll.js b/themes/commerce/components/BlogPostListScroll.js index 7af8c302..91beb929 100644 --- a/themes/commerce/components/BlogPostListScroll.js +++ b/themes/commerce/components/BlogPostListScroll.js @@ -1,4 +1,4 @@ -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import ProductCard from './ProductCard' import BlogPostListEmpty from './BlogPostListEmpty' import { useGlobal } from '@/lib/global' @@ -14,7 +14,7 @@ import { useEffect, useRef, useState } from 'react' * @constructor */ const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG.POST_LIST_SUMMARY, siteInfo }) => { - const postsPerPage = BLOG.POSTS_PER_PAGE + const postsPerPage = parseInt(siteConfig('POSTS_PER_PAGE')) const [page, updatePage] = useState(1) const postsToShow = getListByPage(posts, page, postsPerPage) diff --git a/themes/commerce/components/HexoRecentComments.js b/themes/commerce/components/HexoRecentComments.js index 6ef3a870..db712bea 100644 --- a/themes/commerce/components/HexoRecentComments.js +++ b/themes/commerce/components/HexoRecentComments.js @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import Card from '@/themes/hexo/components/Card' import { useGlobal } from '@/lib/global' import Link from 'next/link' @@ -16,7 +16,7 @@ const HexoRecentComments = (props) => { const [onLoading, changeLoading] = useState(true) useEffect(() => { RecentComments({ - serverURL: BLOG.COMMENT_WALINE_SERVER_URL, + serverURL: siteConfig('COMMENT_WALINE_SERVER_URL'), count: 5 }).then(({ comments }) => { changeLoading(false) diff --git a/themes/commerce/components/LatestPostsGroup.js b/themes/commerce/components/LatestPostsGroup.js index a6d9ace2..7562bce2 100644 --- a/themes/commerce/components/LatestPostsGroup.js +++ b/themes/commerce/components/LatestPostsGroup.js @@ -1,4 +1,4 @@ -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import LazyImage from '@/components/LazyImage' import { useGlobal } from '@/lib/global' // import Image from 'next/image' @@ -28,7 +28,7 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => {
{latestPosts.map(post => { - const selected = currentPath === `${BLOG.SUB_PATH}/${post.slug}` + const selected = currentPath === `${siteConfig('SUB_PATH')}/${post.slug}` const headerImage = post?.pageCoverThumbnail ? post.pageCoverThumbnail : siteInfo?.pageCover @@ -36,7 +36,7 @@ const LatestPostsGroup = ({ latestPosts, siteInfo }) => { ( diff --git a/themes/commerce/components/ProductCard.js b/themes/commerce/components/ProductCard.js index aa2cd0bf..57ea867e 100644 --- a/themes/commerce/components/ProductCard.js +++ b/themes/commerce/components/ProductCard.js @@ -1,6 +1,6 @@ import Link from 'next/link' import CONFIG from '../config' -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import LazyImage from '@/components/LazyImage' // import Image from 'next/image' @@ -19,7 +19,7 @@ const ProductCard = ({ index, post, siteInfo }) => {
{/* 图片封面 */} - +
diff --git a/themes/commerce/components/SideRight.js b/themes/commerce/components/SideRight.js index 570bf32f..7bef60fb 100644 --- a/themes/commerce/components/SideRight.js +++ b/themes/commerce/components/SideRight.js @@ -6,7 +6,7 @@ import Catalog from './Catalog' import { InfoCard } from './InfoCard' import { AnalyticsCard } from './AnalyticsCard' import CONFIG from '../config' -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import dynamic from 'next/dynamic' import Announcement from './Announcement' import { useGlobal } from '@/lib/global' @@ -65,7 +65,7 @@ export default function SideRight(props) { - {BLOG.COMMENT_WALINE_SERVER_URL && BLOG.COMMENT_WALINE_RECENT && } + {siteConfig('COMMENT_WALINE_SERVER_URL') && siteConfig('COMMENT_WALINE_RECENT') && }
{post && post.toc && post.toc.length > 1 && diff --git a/themes/commerce/index.js b/themes/commerce/index.js index ece0fc74..e739127b 100644 --- a/themes/commerce/index.js +++ b/themes/commerce/index.js @@ -60,7 +60,7 @@ const LayoutBase = props => { {/* 主区块 */}
-
+
{' '}   - + {post.title}
diff --git a/themes/example/components/BlogListPage.js b/themes/example/components/BlogListPage.js index 429ee30e..66c33992 100644 --- a/themes/example/components/BlogListPage.js +++ b/themes/example/components/BlogListPage.js @@ -1,5 +1,5 @@ -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import { useRouter } from 'next/router' import Link from 'next/link' @@ -10,7 +10,7 @@ export const BlogListPage = props => { const { page = 1, posts, postCount } = props const { locale } = useGlobal() const router = useRouter() - const totalPage = Math.ceil(postCount / BLOG.POSTS_PER_PAGE) + const totalPage = Math.ceil(postCount / parseInt(siteConfig('POSTS_PER_PAGE'))) const currentPage = +page const showPrev = currentPage > 1 diff --git a/themes/example/components/BlogListScroll.js b/themes/example/components/BlogListScroll.js index 16a0b7eb..686e2e72 100644 --- a/themes/example/components/BlogListScroll.js +++ b/themes/example/components/BlogListScroll.js @@ -1,4 +1,4 @@ -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import { useCallback, useEffect, useRef, useState } from 'react' import throttle from 'lodash.throttle' @@ -13,12 +13,12 @@ export const BlogListScroll = props => { let hasMore = false const postsToShow = posts - ? Object.assign(posts).slice(0, BLOG.POSTS_PER_PAGE * page) + ? Object.assign(posts).slice(0, parseInt(siteConfig('POSTS_PER_PAGE')) * page) : [] if (posts) { const totalCount = posts.length - hasMore = page * BLOG.POSTS_PER_PAGE < totalCount + hasMore = page * parseInt(siteConfig('POSTS_PER_PAGE')) < totalCount } const handleGetMore = () => { if (!hasMore) return diff --git a/themes/example/components/BlogPostCard.js b/themes/example/components/BlogPostCard.js index 5e9bdd33..043b6a51 100644 --- a/themes/example/components/BlogPostCard.js +++ b/themes/example/components/BlogPostCard.js @@ -1,9 +1,8 @@ -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' 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 @@ -42,7 +41,7 @@ const BlogPostCard = ({ post }) => { {/* 图片封面 */} {showPageCover && (
- +
diff --git a/themes/example/components/ExampleRecentComments.js b/themes/example/components/ExampleRecentComments.js index 7e2c3517..e5097740 100644 --- a/themes/example/components/ExampleRecentComments.js +++ b/themes/example/components/ExampleRecentComments.js @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import Link from 'next/link' import { RecentComments } from '@waline/client' @@ -13,7 +13,7 @@ const ExampleRecentComments = (props) => { const [onLoading, changeLoading] = useState(true) useEffect(() => { RecentComments({ - serverURL: BLOG.COMMENT_WALINE_SERVER_URL, + serverURL: siteConfig('COMMENT_WALINE_SERVER_URL'), count: 5 }).then(({ comments }) => { changeLoading(false) diff --git a/themes/example/components/Footer.js b/themes/example/components/Footer.js index dd9f6670..77c8bad6 100644 --- a/themes/example/components/Footer.js +++ b/themes/example/components/Footer.js @@ -1,4 +1,3 @@ -import BLOG from '@/blog.config' import DarkModeButton from '@/components/DarkModeButton' import { siteConfig } from '@/lib/config' @@ -16,10 +15,10 @@ export const Footer = (props) => {
{/* 右侧链接 */} {/* Privacy Policy */} - {BLOG.BEI_AN && ({BLOG.BEI_AN} )} + {siteConfig('BEI_AN') && ({siteConfig('BEI_AN')} )} Powered by - NotionNext {BLOG.VERSION} + NotionNext {siteConfig('VERSION')}
diff --git a/themes/example/components/SideBar.js b/themes/example/components/SideBar.js index 39ffead7..ea0531b7 100644 --- a/themes/example/components/SideBar.js +++ b/themes/example/components/SideBar.js @@ -1,4 +1,4 @@ -import BLOG from '@/blog.config' +import { siteConfig } from '@/lib/config' import Live2D from '@/components/Live2D' import { useGlobal } from '@/lib/global' import Link from 'next/link' @@ -51,7 +51,7 @@ export const SideBar = (props) => { - {BLOG.COMMENT_WALINE_SERVER_URL && BLOG.COMMENT_WALINE_RECENT &&