diff --git a/blog.config.js b/blog.config.js index c35c446d..97b66b9e 100644 --- a/blog.config.js +++ b/blog.config.js @@ -28,8 +28,8 @@ const BLOG = { // 原配置文件过长,且并非所有人都会用到,故此将配置拆分到/conf/目录下, 按需找到对应文件并修改即可 ...require('./conf/comment.config'), // 评论插件 ...require('./conf/contact.config'), // 作者联系方式配置 + ...require('./conf/post.config'), // 文章与列表配置 ...require('./conf/analytics.config'), // 站点访问统计 - ...require('./conf/post.config'), // 博客列表数量、文章url相关配置 ...require('./conf/image.config'), // 网站图片相关配置 ...require('./conf/font.config'), // 网站字体 ...require('./conf/right-click-menu'), // 自定义右键菜单相关配置 diff --git a/conf/post.config.js b/conf/post.config.js index ee89d12f..3e7a4ff3 100644 --- a/conf/post.config.js +++ b/conf/post.config.js @@ -1,5 +1,5 @@ /** - * 博客列表相关配置 + * 文章相关功能 */ module.exports = { // 文章URL前缀 @@ -9,6 +9,9 @@ module.exports = { // 支援類似 WP 可自訂文章連結格式的功能:https://wordpress.org/documentation/article/customize-permalinks/,目前只先實作 %year%/%month%/%day% // 例:如想連結改成前綴 article + 時間戳記,可變更為: 'article/%year%/%month%/%day%' + POST_SCHEDULE_PUBLISH: + process.env.NEXT_PUBLIC_NOTION_SCHEDULE_PUBLISH || true, // 按照文章的发布时间字段,控制自动上下架 + // 分享条 POST_SHARE_BAR_ENABLE: process.env.NEXT_PUBLIC_POST_SHARE_BAR || 'true', //文章底部分享条开关 POSTS_SHARE_SERVICES: diff --git a/lib/config.js b/lib/config.js index 3712d877..54b043a7 100644 --- a/lib/config.js +++ b/lib/config.js @@ -34,6 +34,7 @@ export const siteConfig = (key, defaultVal = null, extendConfig = {}) => { case 'POST_LIST_STYLE': case 'POST_LIST_PREVIEW': case 'POST_URL_PREFIX_MAPPING_CATEGORY': + case 'POST_SCHEDULE_PUBLISH': case 'IS_TAG_COLOR_DISTINGUISHED': case 'TAG_SORT_BY_COUNT': case 'THEME': diff --git a/lib/db/getSiteData.js b/lib/db/getSiteData.js index af55bd25..a40334b5 100755 --- a/lib/db/getSiteData.js +++ b/lib/db/getSiteData.js @@ -238,7 +238,7 @@ async function convertNotionToSiteDate(pageId, from, pageRecordMap) { // 新特性,判断文章的发布和下架时间,如果不在有效期内则进行下架处理 const publish = isInRange(post.date) - if (!publish) { + if (!publish && siteConfig('POST_SCHEDULE_PUBLISH', '', NOTION_CONFIG)) { console.log(post.title, '未处于发布时段 [', post.date, '] 内,将强制隐藏') // 隐藏 post.status = 'Invisible'