diff --git a/blog.config.js b/blog.config.js index d35bb178..79803ce0 100644 --- a/blog.config.js +++ b/blog.config.js @@ -6,15 +6,6 @@ const BLOG = { email: 'tlyong1992@hotmail.com', // 联系邮箱 link: 'https://tangly1024.com', // 网站地址 keywords: ['Notion', '写作', '博客'], // 网站关键词 - home: { // 首页 - showHomeBanner: false, // 首页是否显示大图及标语 [true,false] - homeBannerStrings: ['Hi,我是一个程序员', 'Hi,我是一个打工人', 'Hi,我是一个干饭人', '欢迎来到我的博客🎉'], // 首页大图标语文字 - homeBannerImage: './bg_image.jpg', // 背景图地址 - showPostCover: false, // 文章列表显示封面图 - showPreview: true, // 列表展示文章预览 - previewLines: 12, // 预览文章的篇幅 - showSummary: false // 显示用户自定义摘要 - }, lang: 'zh-CN', // ['zh-CN','en-US'] default lang => see /lib/lang.js for more. notionPageId: process.env.NOTION_PAGE_ID || 'bee1fccfa3bd47a1a7be83cc71372d83', // Important page_id!!! notionAccessToken: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public @@ -26,29 +17,8 @@ const BLOG = { since: 2020, // if leave this empty, current year will be used. postListStyle: 'page', // ['page','scroll] 文章列表样式:页码分页、单页滚动加载 postsPerPage: 6, // post counts per page + previewLines: 12, // 预览博客行数 sortByDate: false, - topNavType: 'normal', // ['fixed','autoCollapse','normal'] 分别是固定顶部、固定底部滑动时自动折叠,不固定 - menu: { // 菜单栏设置 - showAbout: false, // 显示关于 - showCategory: true, // 显示分类 - showTag: true, // 显示标签 - showArchive: true, // 显示归档 - showSearch: true // 显示搜索 - }, - widget: { // 挂件及组件设置 - showPet: false, // 是否显示宠物挂件 - petLink: 'https://cdn.jsdelivr.net/npm/live2d-widget-model-wanko@1.0.5/assets/wanko.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models - showToTop: true, // 是否显示回顶 - showToBottom: false, // 显示回底 - showDarkMode: false, // 显示日间/夜间模式切换 - showToc: true, // 移动端显示悬浮目录 - showShareBar: false, // 文章分享功能 - showRelatePosts: true, // 相关文章推荐 - showCopyRight: true, // 文章版权声明 - showLatestPost: false, // 右侧边栏显示最近更新 - showCategoryList: false, // 右侧边栏显示文章分类列表 - showTagList: false // 右侧边栏显示标签分类列表 - }, socialLink: { // 社交链接,如不需要展示可以留空白,例如 weibo:'' weibo: 'https://weibo.com/tangly1024', twitter: 'https://twitter.com/troy1024_1', diff --git a/pages/index.js b/pages/index.js index 6fbb1073..b4179dbf 100644 --- a/pages/index.js +++ b/pages/index.js @@ -28,7 +28,7 @@ export async function getStaticProps () { ) for (const i in postsToShow) { const post = postsToShow[i] - const blockMap = await getPostBlocks(post.id, 'slug', BLOG.home.previewLines) + const blockMap = await getPostBlocks(post.id, 'slug', BLOG.previewLines) if (blockMap) { post.blockMap = blockMap } diff --git a/pages/page/[page].js b/pages/page/[page].js index 5ed48e0f..569eb389 100644 --- a/pages/page/[page].js +++ b/pages/page/[page].js @@ -44,7 +44,7 @@ export async function getStaticProps ({ params: { page } }) { for (const i in postsToShow) { const post = postsToShow[i] - const blockMap = await getPostBlocks(post.id, 'slug', BLOG.home.previewLines) + const blockMap = await getPostBlocks(post.id, 'slug', BLOG.previewLines) if (blockMap) { post.blockMap = blockMap } diff --git a/themes/NEXT/LayoutBase.js b/themes/NEXT/LayoutBase.js index 4e963b47..92344b00 100644 --- a/themes/NEXT/LayoutBase.js +++ b/themes/NEXT/LayoutBase.js @@ -1,4 +1,3 @@ -import BLOG from '@/blog.config' import CommonHead from '@/components/CommonHead' import FloatDarkModeButton from './components/FloatDarkModeButton' import Footer from './components/Footer' @@ -12,6 +11,7 @@ import { useGlobal } from '@/lib/global' import PropTypes from 'prop-types' import React, { useEffect, useRef, useState } from 'react' import smoothscroll from 'smoothscroll-polyfill' +import CONFIG_NEXT from '@/themes/NEXT/config_next' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 @@ -79,7 +79,7 @@ const LayoutBase = ({
-
+
{onLoading ? : <> diff --git a/themes/NEXT/LayoutIndex.js b/themes/NEXT/LayoutIndex.js index dfa6590b..19993b20 100644 --- a/themes/NEXT/LayoutIndex.js +++ b/themes/NEXT/LayoutIndex.js @@ -4,7 +4,7 @@ import LatestPostsGroup from './components/LatestPostsGroup' import Card from './components/Card' import BlogPostListScroll from './components/BlogPostListScroll' import BlogPostListPage from './components/BlogPostListPage' -import { CONFIG_NEXT } from './index' +import CONFIG_NEXT from './config_next' export const LayoutIndex = ({ posts, tags, meta, categories, postCount, latestPosts }) => { return - {CONFIG_NEXT.POSTS_LIST_TYPE !== 'page' + {CONFIG_NEXT.POST_LIST_TYPE !== 'page' ? ( ) diff --git a/themes/NEXT/LayoutPage.js b/themes/NEXT/LayoutPage.js index 965ffc03..5680c9b9 100644 --- a/themes/NEXT/LayoutPage.js +++ b/themes/NEXT/LayoutPage.js @@ -1,7 +1,7 @@ import LayoutBase from './LayoutBase' import LatestPostsGroup from './components/LatestPostsGroup' import BlogPostListPage from './components/BlogPostListPage' -import { CONFIG_NEXT } from './index' +import CONFIG_NEXT from './config_next' export const LayoutPage = ({ page, posts, tags, meta, categories, postCount, latestPosts }) => { return ( diff --git a/themes/NEXT/LayoutSlug.js b/themes/NEXT/LayoutSlug.js index fc7b7f01..253c7901 100644 --- a/themes/NEXT/LayoutSlug.js +++ b/themes/NEXT/LayoutSlug.js @@ -14,7 +14,7 @@ import 'prismjs/components/prism-javascript' import 'prismjs/components/prism-markup' import 'prismjs/components/prism-python' import 'prismjs/components/prism-typescript' -import { CONFIG_NEXT } from './index' +import CONFIG_NEXT from './config_next' export const LayoutSlug = ({ post, diff --git a/themes/NEXT/components/ArticleCopyright.js b/themes/NEXT/components/ArticleCopyright.js index 61f8f6d9..527d31c6 100644 --- a/themes/NEXT/components/ArticleCopyright.js +++ b/themes/NEXT/components/ArticleCopyright.js @@ -1,9 +1,9 @@ -import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import Link from 'next/link' +import CONFIG_NEXT from '@/themes/NEXT/config_next' export default function ArticleCopyright ({ author, url }) { - if (!BLOG.widget?.showCopyRight) { + if (!CONFIG_NEXT.ARTICLE_COPYRIGHT) { return <> } const { locale } = useGlobal() @@ -11,7 +11,7 @@ export default function ArticleCopyright ({ author, url }) {
  • {locale.COMMON.AUTHOR}: - + {author}
  • diff --git a/themes/NEXT/components/BlogPostCard.js b/themes/NEXT/components/BlogPostCard.js index 9ef97a0b..d127df1c 100644 --- a/themes/NEXT/components/BlogPostCard.js +++ b/themes/NEXT/components/BlogPostCard.js @@ -8,10 +8,11 @@ import React from 'react' import { Code, Collection, CollectionRow, Equation, NotionRenderer } from 'react-notion-x' import Card from './Card' import TagItemMini from './TagItemMini' +import CONFIG_NEXT from '@/themes/NEXT/config_next' const BlogPostCard = ({ post, showSummary }) => { const { locale } = useGlobal() - const showPreview = BLOG.home?.showPreview && post.blockMap + const showPreview = CONFIG_NEXT.POST_LIST_PREVIEW && post.blockMap return (
    @@ -67,7 +68,7 @@ const BlogPostCard = ({ post, showSummary }) => {
    - {BLOG.home?.showPostCover && post?.page_cover && ( + {CONFIG_NEXT.POST_LIST_COVER && post?.page_cover && (
    {post.title} diff --git a/themes/NEXT/components/BlogPostListScroll.js b/themes/NEXT/components/BlogPostListScroll.js index b46250ed..966c956a 100644 --- a/themes/NEXT/components/BlogPostListScroll.js +++ b/themes/NEXT/components/BlogPostListScroll.js @@ -4,16 +4,16 @@ import BlogPostListEmpty from '@/themes/NEXT/components/BlogPostListEmpty' import { useGlobal } from '@/lib/global' import throttle from 'lodash.throttle' import React, { useCallback, useEffect, useRef, useState } from 'react' +import CONFIG_NEXT from '@/themes/NEXT/config_next' /** * 博客列表滚动分页 * @param posts 所有文章 * @param tags 所有标签 - * @param targetRef 指向父容器,用于计算下拉滚动的高度 * @returns {JSX.Element} * @constructor */ -const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = BLOG.home.showSummary }) => { +const BlogPostListScroll = ({ posts = [], currentSearch, showSummary = CONFIG_NEXT.POST_LIST_SUMMARY }) => { const postsPerPage = BLOG.postsPerPage const [page, updatePage] = useState(1) const postsToShow = getPostByPage(page, posts, postsPerPage) diff --git a/themes/NEXT/components/FloatDarkModeButton.js b/themes/NEXT/components/FloatDarkModeButton.js index 6a286fcd..d78a77ae 100644 --- a/themes/NEXT/components/FloatDarkModeButton.js +++ b/themes/NEXT/components/FloatDarkModeButton.js @@ -1,11 +1,11 @@ -import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import { loadUserThemeFromCookies, saveTheme } from '@/lib/theme' import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import CONFIG_NEXT from '@/themes/NEXT/config_next' export default function FloatDarkModeButton () { - if (!BLOG.widget?.showDarkMode) { + if (!CONFIG_NEXT.WIDGET_DARK_MODE) { return <> } diff --git a/themes/NEXT/components/Header.js b/themes/NEXT/components/Header.js index 7170f85e..13eedfdb 100644 --- a/themes/NEXT/components/Header.js +++ b/themes/NEXT/components/Header.js @@ -1,9 +1,9 @@ -import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import { faAngleDown } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useEffect, useState } from 'react' import Typed from 'typed.js' +import CONFIG_NEXT from '@/themes/NEXT/config_next' let wrapperTop = 0 let windowTop = 0 @@ -19,7 +19,7 @@ export default function Header () { if (!typed && window && document.getElementById('typed')) { changeType( new Typed('#typed', { - strings: BLOG.home.homeBannerStrings, + strings: CONFIG_NEXT.HOME_BANNER_Strings, typeSpeed: 200, backSpeed: 100, backDelay: 400, @@ -41,7 +41,7 @@ export default function Header () { const scrollTrigger = () => { if ( (window.scrollY > windowTop) & - (window.scrollY < window.innerHeight) & + (window.scrollY < window.innerHeight) && !autoScroll ) { autoScroll = true @@ -50,7 +50,7 @@ export default function Header () { } if ( (window.scrollY < windowTop) & - (window.scrollY < window.innerHeight) & + (window.scrollY < window.innerHeight) && !autoScroll ) { autoScroll = true @@ -99,7 +99,7 @@ export default function Header () { className="duration-500 md:bg-fixed w-full bg-cover bg-center h-screen bg-black" style={{ backgroundImage: - `linear-gradient(rgba(0, 0, 0, 0.8), rgba(0,0,0,0.2), rgba(0, 0, 0, 0.8) ),url("${BLOG.home.homeBannerImage}")` + `linear-gradient(rgba(0, 0, 0, 0.8), rgba(0,0,0,0.2), rgba(0, 0, 0, 0.8) ),url("${CONFIG_NEXT.HOME_BANNER_IMAGE}")` }} >
    diff --git a/themes/NEXT/components/JumpToBottomButton.js b/themes/NEXT/components/JumpToBottomButton.js index 4ab38bc2..bf024e03 100644 --- a/themes/NEXT/components/JumpToBottomButton.js +++ b/themes/NEXT/components/JumpToBottomButton.js @@ -1,8 +1,8 @@ -import BLOG from '@/blog.config' import { faArrowDown } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import React, { useEffect, useState } from 'react' import smoothscroll from 'smoothscroll-polyfill' +import CONFIG_NEXT from '@/themes/NEXT/config_next' /** * 跳转到网页顶部 @@ -13,7 +13,7 @@ import smoothscroll from 'smoothscroll-polyfill' * @constructor */ const JumpToBottomButton = ({ showPercent = false }) => { - if (!BLOG.widget?.showToBottom) { + if (!CONFIG_NEXT.WIDGET_TO_BOTTOM) { return <> } diff --git a/themes/NEXT/components/JumpToTopButton.js b/themes/NEXT/components/JumpToTopButton.js index 9fb58f9e..e08f3a10 100644 --- a/themes/NEXT/components/JumpToTopButton.js +++ b/themes/NEXT/components/JumpToTopButton.js @@ -1,8 +1,8 @@ -import BLOG from '@/blog.config' import { useGlobal } from '@/lib/global' import { faArrowUp } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import React from 'react' +import CONFIG_NEXT from '@/themes/NEXT/config_next' /** * 跳转到网页顶部 @@ -13,7 +13,7 @@ import React from 'react' * @constructor */ const JumpToTopButton = ({ showPercent = true, percent }) => { - if (!BLOG.widget?.showToTop) { + if (!CONFIG_NEXT.WIDGET_TO_TOP) { return <> } const { locale } = useGlobal() diff --git a/themes/NEXT/components/Live2D.js b/themes/NEXT/components/Live2D.js index e6d924ef..ce99d4d7 100644 --- a/themes/NEXT/components/Live2D.js +++ b/themes/NEXT/components/Live2D.js @@ -1,9 +1,9 @@ /* eslint-disable no-undef */ -import BLOG from '@/blog.config' +import CONFIG_NEXT from '@/themes/NEXT/config_next' let hasLoad = false export default function Live2D () { - if (!BLOG.widget?.showPet) { + if (!CONFIG_NEXT.WIDGET_PET) { return <> } @@ -13,7 +13,7 @@ export default function Live2D () { } return
    - +
    } @@ -25,7 +25,7 @@ function initLive2D () { loadExternalResource('https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/live2d.min.js', 'js') ]).then(() => { // https://github.com/xiazeyu/live2d-widget-models - loadlive2d('live2d', BLOG.widget.petLink) + loadlive2d('live2d', CONFIG_NEXT.WIDGET_PET_LINK) }) } } diff --git a/themes/NEXT/components/MenuButtonGroup.js b/themes/NEXT/components/MenuButtonGroup.js index aef72bc5..a8a730fb 100644 --- a/themes/NEXT/components/MenuButtonGroup.js +++ b/themes/NEXT/components/MenuButtonGroup.js @@ -4,19 +4,19 @@ import { useRouter } from 'next/router' import { useGlobal } from '@/lib/global' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faArchive, faHome, faTag, faTh, faUser } from '@fortawesome/free-solid-svg-icons' -import BLOG from 'blog.config' +import CONFIG_NEXT from '../config_next' -const MenuButtonGroup = ({ allowCollapse = false, postCount }) => { +const MenuButtonGroup = ({ postCount }) => { const { locale } = useGlobal() const router = useRouter() const archiveSlot =
    {postCount}
    const links = [ { id: 0, icon: faHome, name: locale.NAV.INDEX, to: '/' || '/', show: true }, - { id: 1, icon: faTh, name: locale.COMMON.CATEGORY, to: '/category', show: BLOG.menu.showCategory }, - { id: 2, icon: faTag, name: locale.COMMON.TAGS, to: '/tag', show: BLOG.menu.showTag }, - { id: 3, icon: faArchive, name: locale.NAV.ARCHIVE, to: '/archive', slot: archiveSlot, show: BLOG.menu.showArchive }, - { id: 4, icon: faUser, name: locale.NAV.ABOUT, to: '/about', show: BLOG.menu.showAbout } + { id: 1, icon: faTh, name: locale.COMMON.CATEGORY, to: '/category', show: CONFIG_NEXT.MENU_CATEGORY }, + { id: 2, icon: faTag, name: locale.COMMON.TAGS, to: '/tag', show: CONFIG_NEXT.MENU_TAG }, + { id: 3, icon: faArchive, name: locale.NAV.ARCHIVE, to: '/archive', slot: archiveSlot, show: CONFIG_NEXT.MENU_ARCHIVE }, + { id: 4, icon: faUser, name: locale.NAV.ABOUT, to: '/about', show: CONFIG_NEXT.MENU_ABOUT } ] return