Merge pull request #541 from tangly1024/develop

v3.6.2
This commit is contained in:
tangly1024
2022-12-07 16:03:01 +08:00
committed by GitHub
22 changed files with 144 additions and 137 deletions

View File

@@ -1,2 +1,2 @@
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables # 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
NEXT_PUBLIC_VERSION=3.6.1 NEXT_PUBLIC_VERSION=3.6.2

View File

@@ -1,29 +1,26 @@
// 注: process.env.XX是Vercel的环境变量配置方式见https://docs.tangly1024.com/zh/features/personality // 注: process.env.XX是Vercel的环境变量配置方式见https://docs.tangly1024.com/zh/features/personality
const BLOG = { const BLOG = {
// Important page_idDuplicate Template from https://www.notion.so/tanghh/02ab3b8678004aa69e9e415905ef32a5
NOTION_PAGE_ID: process.env.NOTION_PAGE_ID || '02ab3b8678004aa69e9e415905ef32a5',
PSEUDO_STATIC: true, // 伪静态路径开启后所有文章URL都以 .html 结尾。
NEXT_REVALIDATE_SECOND: 5, // 更新内容缓存间隔 单位(秒)即每个页面有5秒的纯静态期、此期间无论多少次访问都不会抓取notion数据调大该值有助于节省Vercel资源、同时提升访问速率但也会使文章更新有延迟。
THEME: process.env.NEXT_PUBLIC_THEME || 'hexo', // 主题, 支持 ['next','hexo',"fukasawa','medium','example'] @see https://preview.tangly1024.com
THEME_SWITCH: process.env.NEXT_PUBLIC_THEME_SWITCH || false, // 是否显示切换主题按钮
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.
APPEARANCE: 'light', // ['light', 'dark', 'auto'], // light 日间模式 dark夜间模式 auto根据时间和主题自动夜间模式
AUTHOR: 'tangly1024', // 作者 AUTHOR: 'tangly1024', // 作者
BIO: '一个普通的干饭人🍚', // 作者简介 BIO: '一个普通的干饭人🍚', // 作者简介
LINK: 'https://tangly1024.com', // 网站地址 LINK: 'https://tangly1024.com', // 网站地址
KEYWORDS: 'Notion, 博客', // 网站关键词 英文逗号隔开 KEYWORDS: 'Notion, 博客', // 网站关键词 英文逗号隔开
NOTION_PAGE_ID: // 社交链接,不需要可留空白,例如 CONTACT_WEIBO:''
process.env.NOTION_PAGE_ID || '02ab3b8678004aa69e9e415905ef32a5', // Important page_idDuplicate Template from https://www.notion.so/tanghh/02ab3b8678004aa69e9e415905ef32a5 CONTACT_EMAIL: 'mail@tangly1024.com', // 邮箱
NOTION_ACCESS_TOKEN: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public CONTACT_WEIBO: '', // 你的微博个人主页
DEBUG: process.env.NEXT_PUBLIC_DEBUG || false, // 是否显示调试按钮 CONTACT_TWITTER: '', // 你的twitter个人主页
CONTACT_GITHUB: 'https://github.com/tangly1024', // 你的github个人主页
// 一个小插件展示你的facebook fan page~ @see https://tw.andys.pro/article/add-facebook-fanpage-notionnext CONTACT_TELEGRAM: 'https://t.me/tangly_1024', // 你的telegram 地址 例如 https://t.me/tangly_1024
FACEBOOK_PAGE_TITLE: CONTACT_LINKEDIN: '', // 你的linkedIn 首页
process.env.NEXT_PUBLIC_FACEBOOK_PAGE_TITLE || null, // 邊欄 Facebook Page widget 的標題欄,填''則無標題欄 e.g FACEBOOK 粉絲團'
FACEBOOK_PAGE:
process.env.NEXT_PUBLIC_FACEBOOK_PAGE || null, // Facebook Page 的連結 e.g https://www.facebook.com/tw.andys.pro
FACEBOOK_PAGE_ID: process.env.NEXT_PUBLIC_FACEBOOK_PAGE_ID || '', // Facebook Page ID 來啟用 messenger 聊天功能
FACEBOOK_APP_ID: process.env.NEXT_PUBLIC_FACEBOOK_APP_ID || '', // Facebook App ID 來啟用 messenger 聊天功能 获取: https://developers.facebook.com/
THEME: process.env.NEXT_PUBLIC_THEME || 'hexo', // 主题, 支持 ['next','hexo',"fukasawa','medium','example'] @see https://preview.tangly1024.com
THEME_SWITCH: process.env.NEXT_PUBLIC_THEME_SWITCH || false, // 是否显示切换主题按钮
LANG: 'zh-CN', // e.g 'zh-CN','en-US' see /lib/lang.js for more.
HOME_BANNER_IMAGE: './bg_image.jpg', // 首页背景大图,默认文件:/public/bg_image.jpg 。会被Notion中的封面图覆盖。
SINCE: 2021, // e.g if leave this empty, current year will be used.
BEI_AN: process.env.NEXT_PUBLIC_BEI_AN || '', // 备案号 闽ICP备XXXXXXX
APPEARANCE: 'light', // ['light', 'dark', 'auto'], // light 日间模式 dark夜间模式 auto根据时间和主题自动夜间模式
// 自定义字体示例: 请先将 CUSTOM_FONT 改为 true 并将 CUSTOM_FONT_URL 改为你的字体CSS地址同时在 CUSTOM_FONT_SANS 与 CUSTOM_FONT_SERIF 中指定你的 fontfamily // 自定义字体示例: 请先将 CUSTOM_FONT 改为 true 并将 CUSTOM_FONT_URL 改为你的字体CSS地址同时在 CUSTOM_FONT_SANS 与 CUSTOM_FONT_SERIF 中指定你的 fontfamily
CUSTOM_FONT: true, // 是否使用自定义字体 CUSTOM_FONT: true, // 是否使用自定义字体
@@ -31,6 +28,14 @@ const BLOG = {
CUSTOM_FONT_SANS: ['LXGW WenKai'], // 自定义无衬线字体 CUSTOM_FONT_SANS: ['LXGW WenKai'], // 自定义无衬线字体
CUSTOM_FONT_SERIF: ['LXGW WenKai'], // 自定义衬线字体 CUSTOM_FONT_SERIF: ['LXGW WenKai'], // 自定义衬线字体
// 一个小插件展示你的facebook fan page~ @see https://tw.andys.pro/article/add-facebook-fanpage-notionnext
FACEBOOK_PAGE_TITLE: process.env.NEXT_PUBLIC_FACEBOOK_PAGE_TITLE || null, // 邊欄 Facebook Page widget 的標題欄,填''則無標題欄 e.g FACEBOOK 粉絲團'
FACEBOOK_PAGE: process.env.NEXT_PUBLIC_FACEBOOK_PAGE || null, // Facebook Page 的連結 e.g https://www.facebook.com/tw.andys.pro
FACEBOOK_PAGE_ID: process.env.NEXT_PUBLIC_FACEBOOK_PAGE_ID || '', // Facebook Page ID 來啟用 messenger 聊天功能
FACEBOOK_APP_ID: process.env.NEXT_PUBLIC_FACEBOOK_APP_ID || '', // Facebook App ID 來啟用 messenger 聊天功能 获取: https://developers.facebook.com/
BEI_AN: process.env.NEXT_PUBLIC_BEI_AN || '', // 备案号 闽ICP备XXXXXXX
// 图标库CDN(可以直接改版本号) // 图标库CDN(可以直接改版本号)
FONT_AWESOME_PATH: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/6.2.0/css/all.min.css', FONT_AWESOME_PATH: 'https://cdn.bootcdn.net/ajax/libs/font-awesome/6.2.0/css/all.min.css',
@@ -39,7 +44,7 @@ const BLOG = {
SUB_PATH: '', // leave this empty unless you want to deploy in a folder SUB_PATH: '', // leave this empty unless you want to deploy in a folder
POST_URL_PREFIX: process.env.NEXT_PUBLIC_POST_URL_PREFIX || 'article', // POST类型文章的默认路径前缀例如默认POST类型的路径是 /article/[slug] POST_URL_PREFIX: process.env.NEXT_PUBLIC_POST_URL_PREFIX || 'article', // POST类型文章的默认路径前缀例如默认POST类型的路径是 /article/[slug]
// 如果此项配置为 '' 空, 则文章将没有前缀路径,使用场景: 希望 文章前缀路径为 /post 的情况 支持多级 // 如果此项配置为 '' 空, 则文章将没有前缀路径,使用场景: 希望文章前缀路径为 /post 的情况 支持多级
POST_LIST_STYLE: 'page', // ['page','scroll] 文章列表样式:页码分页、单页滚动加载 POST_LIST_STYLE: 'page', // ['page','scroll] 文章列表样式:页码分页、单页滚动加载
POST_LIST_PREVIEW: process.env.NEXT_PUBLIC_POST_PREVIEW || 'false', // 是否在列表加载文章预览 POST_LIST_PREVIEW: process.env.NEXT_PUBLIC_POST_PREVIEW || 'false', // 是否在列表加载文章预览
@@ -51,22 +56,12 @@ const BLOG = {
PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量0为不限制 PREVIEW_CATEGORY_COUNT: 16, // 首页最多展示的分类数量0为不限制
PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量0为不限制 PREVIEW_TAG_COUNT: 16, // 首页最多展示的标签数量0为不限制
// 社交链接,不需要可留空白,例如 CONTACT_WEIBO:''
CONTACT_EMAIL: 'mail@tangly1024.com', // 邮箱
CONTACT_WEIBO: '', // 你的微博个人主页
CONTACT_TWITTER: '', // 你的twitter个人主页
CONTACT_GITHUB: 'https://github.com/tangly1024', // 你的github个人主页
CONTACT_TELEGRAM: 'https://t.me/tangly_1024', // 你的telegram 地址 例如 https://t.me/tangly_1024
CONTACT_LINKEDIN: '', // 你的linkedIn 首页
// 鼠标点击烟花特效 // 鼠标点击烟花特效
FIREWORKS: process.env.NEXT_PUBLIC_FIREWORKS || false, // 鼠标点击烟花特效 FIREWORKS: process.env.NEXT_PUBLIC_FIREWORKS || false, // 鼠标点击烟花特效
// 悬浮挂件 // 悬浮挂件
WIDGET_PET: process.env.NEXT_PUBLIC_WIDGET_PET || true, // 是否显示宠物挂件 WIDGET_PET: process.env.NEXT_PUBLIC_WIDGET_PET || true, // 是否显示宠物挂件
WIDGET_PET_LINK: WIDGET_PET_LINK: 'https://cdn.jsdelivr.net/npm/live2d-widget-model-wanko@1.0.5/assets/wanko.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models
'https://cdn.jsdelivr.net/npm/live2d-widget-model-wanko@1.0.5/assets/wanko.model.json', // 挂件模型地址 @see https://github.com/xiazeyu/live2d-widget-models
WIDGET_PET_SWITCH_THEME: true, // 点击宠物挂件切换博客主题 WIDGET_PET_SWITCH_THEME: true, // 点击宠物挂件切换博客主题
// 评论互动 可同时开启多个支持 GISCUS CUSDIS UTTERRANCES GITALK // 评论互动 可同时开启多个支持 GISCUS CUSDIS UTTERRANCES GITALK
@@ -74,40 +69,27 @@ const BLOG = {
// giscus @see https://giscus.app/ // giscus @see https://giscus.app/
COMMENT_GISCUS_REPO: process.env.NEXT_PUBLIC_COMMENT_GISCUS_REPO || '', // 你的Github仓库名 e.g 'tangly1024/NotionNext' COMMENT_GISCUS_REPO: process.env.NEXT_PUBLIC_COMMENT_GISCUS_REPO || '', // 你的Github仓库名 e.g 'tangly1024/NotionNext'
COMMENT_GISCUS_REPO_ID: process.env.NEXT_PUBLIC_COMMENT_GISCUS_REPO_ID || '', // 你的Github Repo ID e.g ( 設定完 giscus 即可看到 ) COMMENT_GISCUS_REPO_ID: process.env.NEXT_PUBLIC_COMMENT_GISCUS_REPO_ID || '', // 你的Github Repo ID e.g ( 設定完 giscus 即可看到 )
COMMENT_GISCUS_CATEGORY_ID: COMMENT_GISCUS_CATEGORY_ID: process.env.NEXT_PUBLIC_COMMENT_GISCUS_CATEGORY_ID || '', // 你的Github Discussions 內的 Category ID ( 設定完 giscus 即可看到 )
process.env.NEXT_PUBLIC_COMMENT_GISCUS_CATEGORY_ID || '', // 你的Github Discussions 內的 Category ID ( 設定完 giscus 即可看到 ) COMMENT_GISCUS_MAPPING: process.env.NEXT_PUBLIC_COMMENT_GISCUS_MAPPING || 'pathname', // 你的Github Discussions 使用哪種方式來標定文章, 預設 'pathname'
COMMENT_GISCUS_MAPPING: COMMENT_GISCUS_REACTIONS_ENABLED: process.env.NEXT_PUBLIC_COMMENT_GISCUS_REACTIONS_ENABLED || '1', // 你的 Giscus 是否開啟文章表情符號 '1' 開啟 "0" 關閉 預設開啟
process.env.NEXT_PUBLIC_COMMENT_GISCUS_MAPPING || 'pathname', // 你的Github Discussions 使用哪種方式來標定文章, 預設 'pathname' COMMENT_GISCUS_EMIT_METADATA: process.env.NEXT_PUBLIC_COMMENT_GISCUS_EMIT_METADATA || '0', // 你的 Giscus 是否提取 Metadata '1' 開啟 '0' 關閉 預設關閉
COMMENT_GISCUS_REACTIONS_ENABLED: COMMENT_GISCUS_INPUT_POSITION: process.env.NEXT_PUBLIC_COMMENT_GISCUS_INPUT_POSITION || 'bottom', // 你的 Giscus 發表留言位置 'bottom' 尾部 'top' 頂部, 預設 'bottom'
process.env.NEXT_PUBLIC_COMMENT_GISCUS_REACTIONS_ENABLED || '1', // 你的 Giscus 是否開啟文章表情符號 '1' 開啟 "0" 關閉 預設開啟
COMMENT_GISCUS_EMIT_METADATA:
process.env.NEXT_PUBLIC_COMMENT_GISCUS_EMIT_METADATA || '0', // 你的 Giscus 是否提取 Metadata '1' 開啟 '0' 關閉 預設關閉
COMMENT_GISCUS_INPUT_POSITION:
process.env.NEXT_PUBLIC_COMMENT_GISCUS_INPUT_POSITION || 'bottom', // 你的 Giscus 發表留言位置 'bottom' 尾部 'top' 頂部, 預設 'bottom'
COMMENT_GISCUS_LANG: process.env.NEXT_PUBLIC_COMMENT_GISCUS_LANG || 'zh-CN', // 你的 Giscus 語言 e.g 'en', 'zh-TW', 'zh-CN', 預設 'en' COMMENT_GISCUS_LANG: process.env.NEXT_PUBLIC_COMMENT_GISCUS_LANG || 'zh-CN', // 你的 Giscus 語言 e.g 'en', 'zh-TW', 'zh-CN', 預設 'en'
COMMENT_GISCUS_LOADING: COMMENT_GISCUS_LOADING: process.env.NEXT_PUBLIC_COMMENT_GISCUS_LOADING || 'lazy', // 你的 Giscus 載入是否漸進式載入, 預設 'lazy'
process.env.NEXT_PUBLIC_COMMENT_GISCUS_LOADING || 'lazy', // 你的 Giscus 載入是否漸進式載入, 預設 'lazy' COMMENT_GISCUS_CROSSORIGIN: process.env.NEXT_PUBLIC_COMMENT_GISCUS_CROSSORIGIN || 'anonymous', // 你的 Giscus 可以跨網域, 預設 'anonymous'
COMMENT_GISCUS_CROSSORIGIN:
process.env.NEXT_PUBLIC_COMMENT_GISCUS_CROSSORIGIN || 'anonymous', // 你的 Giscus 可以跨網域, 預設 'anonymous'
COMMENT_CUSDIS_APP_ID: process.env.NEXT_PUBLIC_COMMENT_CUSDIS_APP_ID || '', // data-app-id 36位 see https://cusdis.com/ COMMENT_CUSDIS_APP_ID: process.env.NEXT_PUBLIC_COMMENT_CUSDIS_APP_ID || '', // data-app-id 36位 see https://cusdis.com/
COMMENT_CUSDIS_HOST: COMMENT_CUSDIS_HOST: process.env.NEXT_PUBLIC_COMMENT_CUSDIS_HOST || 'https://cusdis.com', // data-host, change this if you're using self-hosted version
process.env.NEXT_PUBLIC_COMMENT_CUSDIS_HOST || 'https://cusdis.com', // data-host, change this if you're using self-hosted version COMMENT_CUSDIS_SCRIPT_SRC: process.env.NEXT_PUBLIC_COMMENT_CUSDIS_SCRIPT_SRC || 'https://cusdis.com/js/cusdis.es.js', // change this if you're using self-hosted version
COMMENT_CUSDIS_SCRIPT_SRC:
process.env.NEXT_PUBLIC_COMMENT_CUSDIS_SCRIPT_SRC ||
'https://cusdis.com/js/cusdis.es.js', // change this if you're using self-hosted version
COMMENT_UTTERRANCES_REPO: COMMENT_UTTERRANCES_REPO: process.env.NEXT_PUBLIC_COMMENT_UTTERRANCES_REPO || '', // 你的代码仓库名, 例如我是 'tangly1024/NotionNext' 更多文档参考 https://utteranc.es/
process.env.NEXT_PUBLIC_COMMENT_UTTERRANCES_REPO || '', // 你的代码仓库名, 例如我是 'tangly1024/NotionNext' 更多文档参考 https://utteranc.es/
// gitalk评论插件 更多参考 https://gitalk.github.io/ // gitalk评论插件 更多参考 https://gitalk.github.io/
COMMENT_GITALK_REPO: process.env.NEXT_PUBLIC_COMMENT_GITALK_REPO || '', // 你的Github仓库名例如 'NotionNext' COMMENT_GITALK_REPO: process.env.NEXT_PUBLIC_COMMENT_GITALK_REPO || '', // 你的Github仓库名例如 'NotionNext'
COMMENT_GITALK_OWNER: process.env.NEXT_PUBLIC_COMMENT_GITALK_OWNER || '', // 你的用户名 e.g tangly1024 COMMENT_GITALK_OWNER: process.env.NEXT_PUBLIC_COMMENT_GITALK_OWNER || '', // 你的用户名 e.g tangly1024
COMMENT_GITALK_ADMIN: process.env.NEXT_PUBLIC_COMMENT_GITALK_ADMIN || '', // 管理员用户名、一般是自己 e.g 'tangly1024' COMMENT_GITALK_ADMIN: process.env.NEXT_PUBLIC_COMMENT_GITALK_ADMIN || '', // 管理员用户名、一般是自己 e.g 'tangly1024'
COMMENT_GITALK_CLIENT_ID: COMMENT_GITALK_CLIENT_ID: process.env.NEXT_PUBLIC_COMMENT_GITALK_CLIENT_ID || '', // e.g 20位ID 在gitalk后台获取
process.env.NEXT_PUBLIC_COMMENT_GITALK_CLIENT_ID || '', // e.g 20位ID 在gitalk后台获取 COMMENT_GITALK_CLIENT_SECRET: process.env.NEXT_PUBLIC_COMMENT_GITALK_CLIENT_SECRET || '', // e.g 40位ID 在gitalk后台获取
COMMENT_GITALK_CLIENT_SECRET:
process.env.NEXT_PUBLIC_COMMENT_GITALK_CLIENT_SECRET || '', // e.g 40位ID 在gitalk后台获取
COMMENT_GITALK_DISTRACTION_FREE_MODE: false, // 类似facebook的无干扰模式 COMMENT_GITALK_DISTRACTION_FREE_MODE: false, // 类似facebook的无干扰模式
COMMENT_GITTER_ROOM: process.env.NEXT_PUBLIC_COMMENT_GITTER_ROOM || '', // gitter聊天室 see https://gitter.im/ 不需要则留空 COMMENT_GITTER_ROOM: process.env.NEXT_PUBLIC_COMMENT_GITTER_ROOM || '', // gitter聊天室 see https://gitter.im/ 不需要则留空
@@ -128,16 +110,13 @@ const BLOG = {
ANALYTICS_CNZZ_ID: process.env.NEXT_PUBLIC_ANALYTICS_CNZZ_ID || '', // 只需要填写站长统计的id, [cnzz_id] -> https://s9.cnzz.com/z_stat.php?id=[cnzz_id]&web_id=[cnzz_id] ANALYTICS_CNZZ_ID: process.env.NEXT_PUBLIC_ANALYTICS_CNZZ_ID || '', // 只需要填写站长统计的id, [cnzz_id] -> https://s9.cnzz.com/z_stat.php?id=[cnzz_id]&web_id=[cnzz_id]
ANALYTICS_GOOGLE_ID: process.env.NEXT_PUBLIC_ANALYTICS_GOOGLE_ID || '', // 谷歌Analytics的id e.g: G-XXXXXXXXXX ANALYTICS_GOOGLE_ID: process.env.NEXT_PUBLIC_ANALYTICS_GOOGLE_ID || '', // 谷歌Analytics的id e.g: G-XXXXXXXXXX
ANALYTICS_ACKEE_TRACKER: ANALYTICS_ACKEE_TRACKER: process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_TRACKER || '', // e.g 'https://ackee.tangly1024.net/tracker.js'
process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_TRACKER || '', // e.g 'https://ackee.tangly1024.net/tracker.js' ANALYTICS_ACKEE_DATA_SERVER: process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_DATA_SERVER || '', // e.g https://ackee.tangly1024.net , don't end with a slash
ANALYTICS_ACKEE_DATA_SERVER: ANALYTICS_ACKEE_DOMAIN_ID: process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_DOMAIN_ID || '', // e.g '0e2257a8-54d4-4847-91a1-0311ea48cc7b'
process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_DATA_SERVER || '', // e.g https://ackee.tangly1024.net , don't end with a slash
ANALYTICS_ACKEE_DOMAIN_ID:
process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_DOMAIN_ID || '', // e.g '0e2257a8-54d4-4847-91a1-0311ea48cc7b'
SEO_GOOGLE_SITE_VERIFICATION: SEO_GOOGLE_SITE_VERIFICATION: process.env.NEXT_PUBLIC_SEO_GOOGLE_SITE_VERIFICATION || '', // Remove the value or replace it with your own google site verification code
process.env.NEXT_PUBLIC_SEO_GOOGLE_SITE_VERIFICATION || '', // Remove the value or replace it with your own google site verification code
// 谷歌广告
ADSENSE_GOOGLE_ID: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_ID || '', // 谷歌广告ID e.g ca-pub-xxxxxxxxxxxxxxxx ADSENSE_GOOGLE_ID: process.env.NEXT_PUBLIC_ADSENSE_GOOGLE_ID || '', // 谷歌广告ID e.g ca-pub-xxxxxxxxxxxxxxxx
// 自定义配置notion数据库字段名 // 自定义配置notion数据库字段名
@@ -154,13 +133,16 @@ const BLOG = {
icon: process.env.NEXT_PUBLIC_NOTION_PROPERTY_ICON || 'icon' icon: process.env.NEXT_PUBLIC_NOTION_PROPERTY_ICON || 'icon'
}, },
ENABLE_CACHE: process.env.ENABLE_CACHE || false, // 开启缓存 会将Notion数据缓存在内存中稍微提升访问速度但要更新内容需要多次刷新页面 // 作废配置
AVATAR: '/avatar.png', // 作者头像被notion中的ICON覆盖。若无ICON则取public目录下的avatar.png
AVATAR: '/avatar.png', // 作者头像被notion中的ICON覆盖。如果没有ICON则取public目录下的avatar.png
TITLE: process.env.NEXT_PUBLIC_TITLE || 'NotionNext BLOG', // 站点标题 被notion中的页面标题覆盖 TITLE: process.env.NEXT_PUBLIC_TITLE || 'NotionNext BLOG', // 站点标题 被notion中的页面标题覆盖
DESCRIPTION: HOME_BANNER_IMAGE: './bg_image.jpg', // 首页背景大图, 会被notion中的封面图覆盖若无封面图则会使用代码中的 /public/bg_image.jpg 文件
process.env.NEXT_PUBLIC_DESCRIPTION || '这是一个由NotionNext生成的站点', // 站点描述被notion中的页面描述覆盖 DESCRIPTION: process.env.NEXT_PUBLIC_DESCRIPTION || '这是一个由NotionNext生成的站点', // 站点描述被notion中的页面描述覆盖
// 开发相关
NOTION_ACCESS_TOKEN: process.env.NOTION_ACCESS_TOKEN || '', // Useful if you prefer not to make your database public
DEBUG: process.env.NEXT_PUBLIC_DEBUG || false, // 是否显示调试按钮
ENABLE_CACHE: process.env.ENABLE_CACHE || false, // 开启缓存会将Notion数据缓存在内存中通常在开发调试中使用正式部署开启此功能意义不大。
isProd: process.env.VERCEL_ENV === 'production', // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) isProd: process.env.VERCEL_ENV === 'production' // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) isProd: process.env.VERCEL_ENV === 'production', // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) isProd: process.env.VERCEL_ENV === 'production' // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables)
VERSION: process.env.NEXT_PUBLIC_VERSION // 版本号 VERSION: process.env.NEXT_PUBLIC_VERSION // 版本号
} }

View File

@@ -17,7 +17,7 @@ import mermaid from 'mermaid'
const PrismMac = () => { const PrismMac = () => {
React.useEffect(() => { React.useEffect(() => {
renderPrismMac() renderPrismMac()
}) }, [])
return <></> return <></>
} }
@@ -25,14 +25,6 @@ function renderPrismMac() {
const container = document?.getElementById('container-inner') const container = document?.getElementById('container-inner')
const codeToolBars = container?.getElementsByClassName('code-toolbar') const codeToolBars = container?.getElementsByClassName('code-toolbar')
if (codeToolBars) {
Array.from(codeToolBars).forEach(item => {
const codeBlocks = item.getElementsByTagName('pre')
if (codeBlocks.length === 0) {
item.remove()
}
})
}
// Add line numbers // Add line numbers
const codeBlocks = container?.getElementsByTagName('pre') const codeBlocks = container?.getElementsByTagName('pre')
if (codeBlocks) { if (codeBlocks) {
@@ -45,28 +37,31 @@ function renderPrismMac() {
} }
// 支持 Mermaid // 支持 Mermaid
const mermaids = document.querySelectorAll('.notion-code .language-mermaid') const mermaidPres = document.querySelectorAll('pre.notion-code.language-mermaid')
if (mermaids) { if (mermaidPres) {
for (const e of mermaids) { for (const e of mermaidPres) {
e.parentElement.classList.remove('code-toolbar') const chart = e.querySelector('code').textContent
const chart = e.firstChild.textContent console.log(e.parentElement)
if (e.firstElementChild) { if (chart && !e.querySelector('.mermaid')) {
e.parentElement.remove() const m = document.createElement('div')
continue m.className = 'mermaid'
} m.innerHTML = chart
if (chart) { e.appendChild(m)
e.parentElement.innerHTML = `<div class="mermaid">${chart}</div>`
} }
} }
} }
const mermaidsSvg = document.querySelectorAll('.mermaid') const mermaidsSvg = document.querySelectorAll('.mermaid')
if (mermaidsSvg) { if (mermaidsSvg) {
let needLoad = false
for (const e of mermaidsSvg) { for (const e of mermaidsSvg) {
if (e?.firstChild?.nodeName !== 'svg') { if (e?.firstChild?.nodeName !== 'svg') {
mermaid.contentLoaded() needLoad = true
} }
} }
if (needLoad) {
mermaid.contentLoaded()
}
} }
// 重新渲染之前检查所有的多余text // 重新渲染之前检查所有的多余text

View File

@@ -15,7 +15,7 @@ const WalineComponent = (props) => {
const router = useRouter() const router = useRouter()
const updateWaline = url => { const updateWaline = url => {
if (url !== path) { if (url !== path && waline) {
waline.update(props) waline.update(props)
} }
} }

View File

@@ -224,8 +224,7 @@ async function getPageRecordMapByNotionAPI({ pageId, from }) {
post.type && post.type &&
(post.type === 'Post' || post.type === 'Page') && (post.type === 'Post' || post.type === 'Page') &&
(post.status === 'Published' || post.status === 'Invisible') (post.status === 'Published' || post.status === 'Invisible')
} })
)
// Sort by date // Sort by date
if (BLOG.POSTS_SORT_BY === 'date') { if (BLOG.POSTS_SORT_BY === 'date') {

View File

@@ -76,6 +76,13 @@ export default async function getPageProperties(id, block, schema, authToken, ta
properties.slug = (properties.slug ?? properties.id) properties.slug = (properties.slug ?? properties.id)
} }
// 开启伪静态路径
if (BLOG.PSEUDO_STATIC) {
if (!properties.slug.endsWith('.html')) {
properties.slug += '.html'
}
}
properties.createdTime = formatDate(new Date(value.created_time).toString(), BLOG.LANG) properties.createdTime = formatDate(new Date(value.created_time).toString(), BLOG.LANG)
properties.lastEditedTime = formatDate(new Date(value?.last_edited_time).toString(), BLOG.LANG) properties.lastEditedTime = formatDate(new Date(value?.last_edited_time).toString(), BLOG.LANG)
properties.fullWidth = value.format?.page_full_width ?? false properties.fullWidth = value.format?.page_full_width ?? false
@@ -87,25 +94,25 @@ export default async function getPageProperties(id, block, schema, authToken, ta
}) || [] }) || []
delete properties.content delete properties.content
return properties return properties
}
// 从Block获取封面图;优先取PageCover否则取内容图片
function getImageUrl(imgObj, blockVal) { // 从Block获取封面图;优先取PageCover否则取内容图片
if (!imgObj) { function getImageUrl(imgObj, blockVal) {
return null if (!imgObj) {
} return null
if (imgObj.startsWith('/')) { }
return 'https://www.notion.so' + imgObj // notion内部图片转相对路径为绝对路径 if (imgObj.startsWith('/')) {
} return 'https://www.notion.so' + imgObj // notion内部图片转相对路径为绝对路径
}
if (imgObj.startsWith('http')) {
// 判断如果是notion上传的图片要拼接访问token if (imgObj.startsWith('http')) {
const u = new URL(imgObj) // 判断如果是notion上传的图片要拼接访问token
if (u.pathname.startsWith('/secure.notion-static.com') && u.hostname.endsWith('.amazonaws.com')) { const u = new URL(imgObj)
return defaultMapImageUrl(imgObj, blockVal) // notion上传的图片需要转换请求地址 if (u.pathname.startsWith('/secure.notion-static.com') && u.hostname.endsWith('.amazonaws.com')) {
} return defaultMapImageUrl(imgObj, blockVal) // notion上传的图片需要转换请求地址
} }
}
// 其他图片链接 或 emoji
return imgObj // 其他图片链接 或 emoji
} return imgObj
} }

View File

@@ -1,6 +1,6 @@
{ {
"name": "notion-next", "name": "notion-next",
"version": "3.6.1", "version": "3.6.2",
"homepage": "https://github.com/tangly1024/NotionNext.git", "homepage": "https://github.com/tangly1024/NotionNext.git",
"license": "MIT", "license": "MIT",
"repository": { "repository": {
@@ -40,7 +40,7 @@
"notion-client": "6.15.6", "notion-client": "6.15.6",
"notion-utils": "6.15.6", "notion-utils": "6.15.6",
"preact": "^10.5.15", "preact": "^10.5.15",
"prism-themes": "^1.9.0", "prism-themes": "1.9.0",
"qrcode.react": "^1.0.1", "qrcode.react": "^1.0.1",
"react": "17.0.2", "react": "17.0.2",
"react-cookies": "^0.1.1", "react-cookies": "^0.1.1",

View File

@@ -95,8 +95,11 @@ export async function getStaticPaths() {
} }
export async function getStaticProps({ params: { slug } }) { export async function getStaticProps({ params: { slug } }) {
// slug 是个数组 let fullSlug = slug.join('/')
const fullSlug = slug.join('/') console.log('[读取Notion]', fullSlug)
if (BLOG.PSEUDO_STATIC) {
fullSlug += '.html'
}
const from = `slug-props-${fullSlug}` const from = `slug-props-${fullSlug}`
const props = await getGlobalNotionData({ from }) const props = await getGlobalNotionData({ from })
props.post = props.allPages.find((p) => { props.post = props.allPages.find((p) => {
@@ -106,13 +109,13 @@ export async function getStaticProps({ params: { slug } }) {
if (!props.post) { if (!props.post) {
const pageId = slug.slice(-1)[0] const pageId = slug.slice(-1)[0]
if (pageId.length < 32) { if (pageId.length < 32) {
return { props, revalidate: 1 } return { props, revalidate: BLOG.NEXT_REVALIDATE_SECOND }
} }
const post = await getNotion(pageId) const post = await getNotion(pageId)
if (post) { if (post) {
props.post = post props.post = post
} else { } else {
return { props, revalidate: 1 } return { props, revalidate: BLOG.NEXT_REVALIDATE_SECOND }
} }
} else { } else {
props.post.blockMap = await getPostBlocks(props.post.id, 'slug') props.post.blockMap = await getPostBlocks(props.post.id, 'slug')
@@ -130,7 +133,7 @@ export async function getStaticProps({ params: { slug } }) {
delete props.allPages delete props.allPages
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -2,6 +2,7 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import React from 'react' import React from 'react'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import * as ThemeMap from '@/themes' import * as ThemeMap from '@/themes'
import BLOG from '@/blog.config'
const ArchiveIndex = props => { const ArchiveIndex = props => {
const { theme, locale } = useGlobal() const { theme, locale } = useGlobal()
@@ -26,7 +27,7 @@ export async function getStaticProps() {
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -52,7 +52,7 @@ export async function getStaticProps({ params: { category } }) {
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -47,7 +47,7 @@ export async function getStaticProps({ params: { category, page } }) {
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -3,6 +3,7 @@ import React from 'react'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import * as ThemeMap from '@/themes' import * as ThemeMap from '@/themes'
import { getAllCategories } from '@/lib/notion/getAllCategories' import { getAllCategories } from '@/lib/notion/getAllCategories'
import BLOG from '@/blog.config'
/** /**
* 分类首页 * 分类首页
@@ -30,6 +31,6 @@ export async function getStaticProps() {
delete props.categoryOptions delete props.categoryOptions
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -44,7 +44,7 @@ export async function getStaticProps() {
meta, meta,
...props ...props
}, },
revalidate: 5 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -56,7 +56,7 @@ export async function getStaticProps({ params: { page } }) {
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -48,7 +48,7 @@ export async function getStaticProps({ params: { keyword } }) {
props.keyword = keyword props.keyword = keyword
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -45,7 +45,7 @@ export async function getStaticProps({ params: { keyword, page } }) {
props.page = page props.page = page
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -2,6 +2,7 @@ import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import * as ThemeMap from '@/themes' import * as ThemeMap from '@/themes'
import BLOG from '@/blog.config'
const Search = props => { const Search = props => {
const { posts, siteInfo } = props const { posts, siteInfo } = props
@@ -58,7 +59,7 @@ export async function getStaticProps() {
props.posts = allPosts props.posts = allPosts
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -43,7 +43,7 @@ export async function getStaticProps({ params: { tag } }) {
props.tag = tag props.tag = tag
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -38,7 +38,7 @@ export async function getStaticProps({ params: { tag, page } }) {
delete props.allPages delete props.allPages
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -3,6 +3,7 @@ import React from 'react'
import { useGlobal } from '@/lib/global' import { useGlobal } from '@/lib/global'
import * as ThemeMap from '@/themes' import * as ThemeMap from '@/themes'
import { getAllTags } from '@/lib/notion' import { getAllTags } from '@/lib/notion'
import BLOG from '@/blog.config'
/** /**
* 标签首页 * 标签首页
@@ -31,7 +32,7 @@ export async function getStaticProps() {
delete props.tagOptions delete props.tagOptions
return { return {
props, props,
revalidate: 1 revalidate: BLOG.NEXT_REVALIDATE_SECOND
} }
} }

View File

@@ -1949,4 +1949,12 @@ pre[class*='language-'] {
::selection { ::selection {
@apply bg-blue-500 text-gray-50 !important; @apply bg-blue-500 text-gray-50 !important;
}
.dark img{
@apply opacity-80
}
.dark #live2d {
@apply opacity-80
} }

View File

@@ -4,6 +4,7 @@
.code-toolbar { .code-toolbar {
position: relative; position: relative;
box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .4); box-shadow: 0 10px 30px 0 rgba(0, 0, 0, .4);
padding-bottom: 0 !important;
@apply mb-8 mt-4 pt-6 w-full rounded-lg bg-black @apply mb-8 mt-4 pt-6 w-full rounded-lg bg-black
} }
@@ -60,6 +61,14 @@ pre[class*='language-'] {
} }
pre[class*="language-mermaid"] { pre[class*="language-mermaid"] {
background: transparent !important; @apply bg-gray-50 dark:bg-gray-200 !important;
@apply dark:bg-gray-200 !important; }
/* mermaid 原文隐藏 */
code.language-mermaid {
display:none
}
pre.notion-code.line-numbers{
margin-bottom: 0 !important
} }