From 734f60593a3bd21f5b7232c18c58911847ff5417 Mon Sep 17 00:00:00 2001 From: Zhenye Dong Date: Sun, 10 Nov 2024 17:57:05 +0800 Subject: [PATCH 1/7] refactor: improve version management - Move version number from env to package.json - Add dynamic version loading with fallback - Improve error handling for version loading --- blog.config.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/blog.config.js b/blog.config.js index 772cae9b671..ed0721cccf6 100644 --- a/blog.config.js +++ b/blog.config.js @@ -548,7 +548,15 @@ const BLOG = { process.env.npm_lifecycle_event === 'export', // 在打包过程中默认开启缓存,开发或运行时开启此功能意义不大。 isProd: process.env.VERCEL_ENV === 'production' || process.env.EXPORT, // distinguish between development and production environment (ref: https://vercel.com/docs/environment-variables#system-environment-variables) BUNDLE_ANALYZER: process.env.ANALYZE === 'true' || false, // 是否展示编译依赖内容与大小 - VERSION: process.env.NEXT_PUBLIC_VERSION // 版本号 + VERSION: (() => { + try { + // 优先使用环境变量,否则从package.json中获取版本号 + return process.env.NEXT_PUBLIC_VERSION || require('./package.json').version + } catch (error) { + console.warn('Failed to load package.json version:', error) + return '1.0.0' // 缺省版本号 + } + })() } module.exports = BLOG From e53db9ef727ae4b0e2229232ad264684b6462faf Mon Sep 17 00:00:00 2001 From: Zhenye Dong Date: Sun, 10 Nov 2024 17:57:34 +0800 Subject: [PATCH 2/7] Remove .env.local file --- .env.local | 176 ----------------------------------------------------- 1 file changed, 176 deletions(-) delete mode 100644 .env.local diff --git a/.env.local b/.env.local deleted file mode 100644 index 6952a6160be..00000000000 --- a/.env.local +++ /dev/null @@ -1,176 +0,0 @@ -# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables -NEXT_PUBLIC_VERSION=4.7.7 - - -# 可在此添加环境变量,去掉最左边的(# )注释即可 -# Notion页面ID,必须 -# NOTION_PAGE_ID=097e5f674880459d8e1b4407758dc4fb - -# 非必须 -# NEXT_PUBLIC_PSEUDO_STATIC= -# NEXT_PUBLIC_REVALIDATE_SECOND= -# NEXT_PUBLIC_THEME=matery -# NEXT_PUBLIC_THEME_SWITCH= -# NEXT_PUBLIC_LANG= -# NEXT_PUBLIC_APPEARANCE= -# NEXT_PUBLIC_APPEARANCE_DARK_TIME= -# NEXT_PUBLIC_GREETING_WORDS= -# NEXT_PUBLIC_CUSTOM_MENU= -# NEXT_PUBLIC_AUTHOR= -# NEXT_PUBLIC_BIO= -# NEXT_PUBLIC_LINK= -# NEXT_PUBLIC_KEYWORD= -# NEXT_PUBLIC_CONTACT_EMAIL= -# NEXT_PUBLIC_CONTACT_WEIBO= -# NEXT_PUBLIC_CONTACT_TWITTER= -# NEXT_PUBLIC_CONTACT_GITHUB= -# NEXT_PUBLIC_CONTACT_TELEGRAM= -# NEXT_PUBLIC_CONTACT_LINKEDIN= -# NEXT_PUBLIC_CONTACT_INSTAGRAM= -# NEXT_PUBLIC_CONTACT_BILIBILI= -# NEXT_PUBLIC_CONTACT_YOUTUBE= -# NEXT_PUBLIC_FAVICON= -# NEXT_PUBLIC_FONT_STYLE= -# NEXT_PUBLIC_FONT_URL= -# NEXT_PUBLIC_FONT_SANS= -# NEXT_PUBLIC_FONT_SERIF= -# NEXT_PUBLIC_FONT_AWESOME_PATH= -# NEXT_PUBLIC_PRISM_THEME_PREFIX_PATH= -# NEXT_PUBLIC_PRISM_THEME_SWITCH= -# NEXT_PUBLIC_PRISM_THEME_LIGHT_PATH= -# NEXT_PUBLIC_PRISM_THEME_DARK_PATH= -# NEXT_PUBLIC_CODE_MAC_BAR= -# NEXT_PUBLIC_CODE_LINE_NUMBERS= -# NEXT_PUBLIC_CODE_COLLAPSE= -# NEXT_PUBLIC_CODE_COLLAPSE_EXPAND_DEFAULT= -# NEXT_PUBLIC_MERMAID_CDN= -# NEXT_PUBLIC_QR_CODE_CDN= -# NEXT_PUBLIC_BACKGROUND_LIGHT= -# NEXT_PUBLIC_BACKGROUND_DARK= -# NEXT_PUBLIC_SUB_PATH= -# NEXT_PUBLIC_POST_SHARE_BAR= -# NEXT_PUBLIC_POST_SHARE_SERVICES= -# NEXT_PUBLIC_POST_URL_PREFIX= -# NEXT_PUBLIC_POST_LIST_STYLE= -# NEXT_PUBLIC_POST_PREVIEW= -# NEXT_PUBLIC_POST_RECOMMEND_COUNT= -# NEXT_PUBLIC_POSTS_PER_PAGE= -# NEXT_PUBLIC_POST_SORT_BY= -# NEXT_PUBLIC_ALGOLIA_APP_ID= -# ALGOLIA_ADMIN_APP_KEY= -# NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_APP_KEY= -# NEXT_PUBLIC_ALGOLIA_INDEX= -# NEXT_PUBLIC_PREVIEW_CATEGORY_COUNT= -# NEXT_PUBLIC_PREVIEW_TAG_COUNT= -# NEXT_PUBLIC_POST_TITLE_ICON= -# NEXT_PUBLIC_POST_DISABLE_GALLERY_CLICK= -# NEXT_PUBLIC_FIREWORKS= -# NEXT_PUBLIC_FIREWORKS_COLOR= -# NEXT_PUBLIC_SAKURA= -# NEXT_PUBLIC_NEST= -# NEXT_PUBLIC_FLUTTERINGRIBBON= -# NEXT_PUBLIC_RIBBON= -# NEXT_PUBLIC_STARRY_SKY= -# NEXT_PUBLIC_CHATBASE_ID= -# NEXT_PUBLIC_WEB_WHIZ_ENABLED= -# NEXT_PUBLIC_WEB_WHIZ_BASE_URL= -# NEXT_PUBLIC_WEB_WHIZ_CHAT_BOT_ID= -# NEXT_PUBLIC_WIDGET_PET= -# NEXT_PUBLIC_WIDGET_PET_LINK= -# NEXT_PUBLIC_WIDGET_PET_SWITCH_THEME= -# NEXT_PUBLIC_MUSIC_PLAYER= -# NEXT_PUBLIC_MUSIC_PLAYER_VISIBLE= -# NEXT_PUBLIC_MUSIC_PLAYER_AUTO_PLAY= -# NEXT_PUBLIC_MUSIC_PLAYER_LRC_TYPE= -# NEXT_PUBLIC_MUSIC_PLAYER_CDN_URL= -# NEXT_PUBLIC_MUSIC_PLAYER_ORDER= -# NEXT_PUBLIC_MUSIC_PLAYER_AUDIO_LIST= -# NEXT_PUBLIC_MUSIC_PLAYER_METING= -# NEXT_PUBLIC_MUSIC_PLAYER_METING_SERVER= -# NEXT_PUBLIC_MUSIC_PLAYER_METING_ID= -# NEXT_PUBLIC_MUSIC_PLAYER_METING_LRC_TYPE= -# NEXT_PUBLIC_COMMENT_ARTALK_SERVER= -# NEXT_PUBLIC_COMMENT_ARTALK_JS= -# NEXT_PUBLIC_COMMENT_ARTALK_CSS= -# NEXT_PUBLIC_COMMENT_ENV_ID= -# NEXT_PUBLIC_COMMENT_TWIKOO_COUNT_ENABLE= -# NEXT_PUBLIC_COMMENT_TWIKOO_CDN_URL= -# NEXT_PUBLIC_COMMENT_UTTERRANCES_REPO= -# NEXT_PUBLIC_COMMENT_GISCUS_REPO= -# NEXT_PUBLIC_COMMENT_GISCUS_REPO_ID= -# NEXT_PUBLIC_COMMENT_GISCUS_CATEGORY_ID= -# NEXT_PUBLIC_COMMENT_GISCUS_MAPPING= -# NEXT_PUBLIC_COMMENT_GISCUS_REACTIONS_ENABLED= -# NEXT_PUBLIC_COMMENT_GISCUS_EMIT_METADATA= -# NEXT_PUBLIC_COMMENT_GISCUS_INPUT_POSITION= -# NEXT_PUBLIC_COMMENT_GISCUS_LANG= -# NEXT_PUBLIC_COMMENT_GISCUS_LOADING= -# NEXT_PUBLIC_COMMENT_GISCUS_CROSSORIGIN= -# NEXT_PUBLIC_COMMENT_CUSDIS_APP_ID= -# NEXT_PUBLIC_COMMENT_CUSDIS_HOST= -# NEXT_PUBLIC_COMMENT_CUSDIS_SCRIPT_SRC= -# NEXT_PUBLIC_COMMENT_GITALK_REPO= -# NEXT_PUBLIC_COMMENT_GITALK_OWNER= -# NEXT_PUBLIC_COMMENT_GITALK_ADMIN= -# NEXT_PUBLIC_COMMENT_GITALK_CLIENT_ID= -# NEXT_PUBLIC_COMMENT_GITALK_CLIENT_SECRET= -# NEXT_PUBLIC_COMMENT_GITALK_JS_CDN_URL= -# NEXT_PUBLIC_COMMENT_GITALK_CSS_CDN_URL= -# NEXT_PUBLIC_COMMENT_GITTER_ROOM= -# NEXT_PUBLIC_COMMENT_DAO_VOICE_ID= -# NEXT_PUBLIC_COMMENT_TIDIO_ID= -# NEXT_PUBLIC_VALINE_CDN= -# NEXT_PUBLIC_VALINE_ID= -# NEXT_PUBLIC_VALINE_KEY= -# NEXT_PUBLIC_VALINE_SERVER_URLS= -# NEXT_PUBLIC_VALINE_PLACEHOLDER= -# NEXT_PUBLIC_WALINE_SERVER_URL= -# NEXT_PUBLIC_WALINE_RECENT= -# NEXT_PUBLIC_WEBMENTION_ENABLE= -# NEXT_PUBLIC_WEBMENTION_AUTH= -# NEXT_PUBLIC_WEBMENTION_HOSTNAME= -# NEXT_PUBLIC_TWITTER_USERNAME= -# NEXT_PUBLIC_WEBMENTION_TOKEN= -# NEXT_PUBLIC_ANALYTICS_VERCEL= -# NEXT_PUBLIC_ANALYTICS_BUSUANZI_ENABLE= -# NEXT_PUBLIC_ANALYTICS_BAIDU_ID= -# NEXT_PUBLIC_ANALYTICS_CNZZ_ID= -# NEXT_PUBLIC_ANALYTICS_GOOGLE_ID= -# NEXT_PUBLIC_ANALYTICS_ACKEE_TRACKER= -# NEXT_PUBLIC_ANALYTICS_ACKEE_DATA_SERVER= -# NEXT_PUBLIC_ANALYTICS_ACKEE_DOMAIN_ID= -# NEXT_PUBLIC_SEO_GOOGLE_SITE_VERIFICATION= -# NEXT_PUBLIC_SEO_BAIDU_SITE_VERIFICATION= -# NEXT_PUBLIC_ADSENSE_GOOGLE_ID= -# NEXT_PUBLIC_ADSENSE_GOOGLE_TEST= -# NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_IN_ARTICLE= -# NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_FLOW= -# NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_NATIVE= -# NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_AUTO= -# NEXT_PUBLIC_WWAD_ID= -# NEXT_PUBLIC_WWADS_AD_BLOCK_DETECT= -# NEXT_PUBLIC_NOTION_PROPERTY_PASSWORD= -# NEXT_PUBLIC_NOTION_PROPERTY_TYPE= -# NEXT_PUBLIC_NOTION_PROPERTY_TYPE_POST= -# NEXT_PUBLIC_NOTION_PROPERTY_TYPE_PAGE= -# NEXT_PUBLIC_NOTION_PROPERTY_TYPE_NOTICE= -# NEXT_PUBLIC_NOTION_PROPERTY_TYPE_MENU= -# NEXT_PUBLIC_NOTION_PROPERTY_TYPE_SUB_MENU= -# NEXT_PUBLIC_NOTION_PROPERTY_TITLE= -# NEXT_PUBLIC_NOTION_PROPERTY_STATUS= -# NEXT_PUBLIC_NOTION_PROPERTY_STATUS_PUBLISH= -# NEXT_PUBLIC_NOTION_PROPERTY_STATUS_INVISIBLE= -# NEXT_PUBLIC_NOTION_PROPERTY_SUMMARY= -# NEXT_PUBLIC_NOTION_PROPERTY_SLUG= -# NEXT_PUBLIC_NOTION_PROPERTY_CATEGORY= -# NEXT_PUBLIC_NOTION_PROPERTY_DATE= -# NEXT_PUBLIC_NOTION_PROPERTY_TAGS= -# NEXT_PUBLIC_NOTION_PROPERTY_ICON= -# NEXT_PUBLIC_ENABLE_RSS= -# NEXT_PUBLIC_IS_TAG_COLOR_DISTINGUISHED= -# MAILCHIMP_LIST_ID= -# MAILCHIMP_API_KEY= -# NEXT_PUBLIC_DEBUG= -# ENABLE_CACHE= -# VERCEL_ENV= -# NEXT_PUBLIC_VERSION= From 04ee6b04c5015bcd3febdeef71e83b0defbf06bc Mon Sep 17 00:00:00 2001 From: Zhenye Dong Date: Sun, 10 Nov 2024 17:58:34 +0800 Subject: [PATCH 3/7] Add .env.example file with no pre-enabled configuration --- .env.example | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 00000000000..eb29e18cf32 --- /dev/null +++ b/.env.example @@ -0,0 +1,175 @@ +# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables + +# 可在此添加环境变量,去掉最左边的(# )注释即可 +# Notion页面ID,必须 +# NOTION_PAGE_ID=097e5f674880459d8e1b4407758dc4fb + +# 非必须 +# NEXT_PUBLIC_VERSION= +# NEXT_PUBLIC_PSEUDO_STATIC= +# NEXT_PUBLIC_REVALIDATE_SECOND= +# NEXT_PUBLIC_THEME=matery +# NEXT_PUBLIC_THEME_SWITCH= +# NEXT_PUBLIC_LANG= +# NEXT_PUBLIC_APPEARANCE= +# NEXT_PUBLIC_APPEARANCE_DARK_TIME= +# NEXT_PUBLIC_GREETING_WORDS= +# NEXT_PUBLIC_CUSTOM_MENU= +# NEXT_PUBLIC_AUTHOR= +# NEXT_PUBLIC_BIO= +# NEXT_PUBLIC_LINK= +# NEXT_PUBLIC_KEYWORD= +# NEXT_PUBLIC_CONTACT_EMAIL= +# NEXT_PUBLIC_CONTACT_WEIBO= +# NEXT_PUBLIC_CONTACT_TWITTER= +# NEXT_PUBLIC_CONTACT_GITHUB= +# NEXT_PUBLIC_CONTACT_TELEGRAM= +# NEXT_PUBLIC_CONTACT_LINKEDIN= +# NEXT_PUBLIC_CONTACT_INSTAGRAM= +# NEXT_PUBLIC_CONTACT_BILIBILI= +# NEXT_PUBLIC_CONTACT_YOUTUBE= +# NEXT_PUBLIC_FAVICON= +# NEXT_PUBLIC_FONT_STYLE= +# NEXT_PUBLIC_FONT_URL= +# NEXT_PUBLIC_FONT_SANS= +# NEXT_PUBLIC_FONT_SERIF= +# NEXT_PUBLIC_FONT_AWESOME_PATH= +# NEXT_PUBLIC_PRISM_THEME_PREFIX_PATH= +# NEXT_PUBLIC_PRISM_THEME_SWITCH= +# NEXT_PUBLIC_PRISM_THEME_LIGHT_PATH= +# NEXT_PUBLIC_PRISM_THEME_DARK_PATH= +# NEXT_PUBLIC_CODE_MAC_BAR= +# NEXT_PUBLIC_CODE_LINE_NUMBERS= +# NEXT_PUBLIC_CODE_COLLAPSE= +# NEXT_PUBLIC_CODE_COLLAPSE_EXPAND_DEFAULT= +# NEXT_PUBLIC_MERMAID_CDN= +# NEXT_PUBLIC_QR_CODE_CDN= +# NEXT_PUBLIC_BACKGROUND_LIGHT= +# NEXT_PUBLIC_BACKGROUND_DARK= +# NEXT_PUBLIC_SUB_PATH= +# NEXT_PUBLIC_POST_SHARE_BAR= +# NEXT_PUBLIC_POST_SHARE_SERVICES= +# NEXT_PUBLIC_POST_URL_PREFIX= +# NEXT_PUBLIC_POST_LIST_STYLE= +# NEXT_PUBLIC_POST_PREVIEW= +# NEXT_PUBLIC_POST_RECOMMEND_COUNT= +# NEXT_PUBLIC_POSTS_PER_PAGE= +# NEXT_PUBLIC_POST_SORT_BY= +# NEXT_PUBLIC_ALGOLIA_APP_ID= +# ALGOLIA_ADMIN_APP_KEY= +# NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_APP_KEY= +# NEXT_PUBLIC_ALGOLIA_INDEX= +# NEXT_PUBLIC_PREVIEW_CATEGORY_COUNT= +# NEXT_PUBLIC_PREVIEW_TAG_COUNT= +# NEXT_PUBLIC_POST_TITLE_ICON= +# NEXT_PUBLIC_POST_DISABLE_GALLERY_CLICK= +# NEXT_PUBLIC_FIREWORKS= +# NEXT_PUBLIC_FIREWORKS_COLOR= +# NEXT_PUBLIC_SAKURA= +# NEXT_PUBLIC_NEST= +# NEXT_PUBLIC_FLUTTERINGRIBBON= +# NEXT_PUBLIC_RIBBON= +# NEXT_PUBLIC_STARRY_SKY= +# NEXT_PUBLIC_CHATBASE_ID= +# NEXT_PUBLIC_WEB_WHIZ_ENABLED= +# NEXT_PUBLIC_WEB_WHIZ_BASE_URL= +# NEXT_PUBLIC_WEB_WHIZ_CHAT_BOT_ID= +# NEXT_PUBLIC_WIDGET_PET= +# NEXT_PUBLIC_WIDGET_PET_LINK= +# NEXT_PUBLIC_WIDGET_PET_SWITCH_THEME= +# NEXT_PUBLIC_MUSIC_PLAYER= +# NEXT_PUBLIC_MUSIC_PLAYER_VISIBLE= +# NEXT_PUBLIC_MUSIC_PLAYER_AUTO_PLAY= +# NEXT_PUBLIC_MUSIC_PLAYER_LRC_TYPE= +# NEXT_PUBLIC_MUSIC_PLAYER_CDN_URL= +# NEXT_PUBLIC_MUSIC_PLAYER_ORDER= +# NEXT_PUBLIC_MUSIC_PLAYER_AUDIO_LIST= +# NEXT_PUBLIC_MUSIC_PLAYER_METING= +# NEXT_PUBLIC_MUSIC_PLAYER_METING_SERVER= +# NEXT_PUBLIC_MUSIC_PLAYER_METING_ID= +# NEXT_PUBLIC_MUSIC_PLAYER_METING_LRC_TYPE= +# NEXT_PUBLIC_COMMENT_ARTALK_SERVER= +# NEXT_PUBLIC_COMMENT_ARTALK_JS= +# NEXT_PUBLIC_COMMENT_ARTALK_CSS= +# NEXT_PUBLIC_COMMENT_ENV_ID= +# NEXT_PUBLIC_COMMENT_TWIKOO_COUNT_ENABLE= +# NEXT_PUBLIC_COMMENT_TWIKOO_CDN_URL= +# NEXT_PUBLIC_COMMENT_UTTERRANCES_REPO= +# NEXT_PUBLIC_COMMENT_GISCUS_REPO= +# NEXT_PUBLIC_COMMENT_GISCUS_REPO_ID= +# NEXT_PUBLIC_COMMENT_GISCUS_CATEGORY_ID= +# NEXT_PUBLIC_COMMENT_GISCUS_MAPPING= +# NEXT_PUBLIC_COMMENT_GISCUS_REACTIONS_ENABLED= +# NEXT_PUBLIC_COMMENT_GISCUS_EMIT_METADATA= +# NEXT_PUBLIC_COMMENT_GISCUS_INPUT_POSITION= +# NEXT_PUBLIC_COMMENT_GISCUS_LANG= +# NEXT_PUBLIC_COMMENT_GISCUS_LOADING= +# NEXT_PUBLIC_COMMENT_GISCUS_CROSSORIGIN= +# NEXT_PUBLIC_COMMENT_CUSDIS_APP_ID= +# NEXT_PUBLIC_COMMENT_CUSDIS_HOST= +# NEXT_PUBLIC_COMMENT_CUSDIS_SCRIPT_SRC= +# NEXT_PUBLIC_COMMENT_GITALK_REPO= +# NEXT_PUBLIC_COMMENT_GITALK_OWNER= +# NEXT_PUBLIC_COMMENT_GITALK_ADMIN= +# NEXT_PUBLIC_COMMENT_GITALK_CLIENT_ID= +# NEXT_PUBLIC_COMMENT_GITALK_CLIENT_SECRET= +# NEXT_PUBLIC_COMMENT_GITALK_JS_CDN_URL= +# NEXT_PUBLIC_COMMENT_GITALK_CSS_CDN_URL= +# NEXT_PUBLIC_COMMENT_GITTER_ROOM= +# NEXT_PUBLIC_COMMENT_DAO_VOICE_ID= +# NEXT_PUBLIC_COMMENT_TIDIO_ID= +# NEXT_PUBLIC_VALINE_CDN= +# NEXT_PUBLIC_VALINE_ID= +# NEXT_PUBLIC_VALINE_KEY= +# NEXT_PUBLIC_VALINE_SERVER_URLS= +# NEXT_PUBLIC_VALINE_PLACEHOLDER= +# NEXT_PUBLIC_WALINE_SERVER_URL= +# NEXT_PUBLIC_WALINE_RECENT= +# NEXT_PUBLIC_WEBMENTION_ENABLE= +# NEXT_PUBLIC_WEBMENTION_AUTH= +# NEXT_PUBLIC_WEBMENTION_HOSTNAME= +# NEXT_PUBLIC_TWITTER_USERNAME= +# NEXT_PUBLIC_WEBMENTION_TOKEN= +# NEXT_PUBLIC_ANALYTICS_VERCEL= +# NEXT_PUBLIC_ANALYTICS_BUSUANZI_ENABLE= +# NEXT_PUBLIC_ANALYTICS_BAIDU_ID= +# NEXT_PUBLIC_ANALYTICS_CNZZ_ID= +# NEXT_PUBLIC_ANALYTICS_GOOGLE_ID= +# NEXT_PUBLIC_ANALYTICS_ACKEE_TRACKER= +# NEXT_PUBLIC_ANALYTICS_ACKEE_DATA_SERVER= +# NEXT_PUBLIC_ANALYTICS_ACKEE_DOMAIN_ID= +# NEXT_PUBLIC_SEO_GOOGLE_SITE_VERIFICATION= +# NEXT_PUBLIC_SEO_BAIDU_SITE_VERIFICATION= +# NEXT_PUBLIC_ADSENSE_GOOGLE_ID= +# NEXT_PUBLIC_ADSENSE_GOOGLE_TEST= +# NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_IN_ARTICLE= +# NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_FLOW= +# NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_NATIVE= +# NEXT_PUBLIC_ADSENSE_GOOGLE_SLOT_AUTO= +# NEXT_PUBLIC_WWAD_ID= +# NEXT_PUBLIC_WWADS_AD_BLOCK_DETECT= +# NEXT_PUBLIC_NOTION_PROPERTY_PASSWORD= +# NEXT_PUBLIC_NOTION_PROPERTY_TYPE= +# NEXT_PUBLIC_NOTION_PROPERTY_TYPE_POST= +# NEXT_PUBLIC_NOTION_PROPERTY_TYPE_PAGE= +# NEXT_PUBLIC_NOTION_PROPERTY_TYPE_NOTICE= +# NEXT_PUBLIC_NOTION_PROPERTY_TYPE_MENU= +# NEXT_PUBLIC_NOTION_PROPERTY_TYPE_SUB_MENU= +# NEXT_PUBLIC_NOTION_PROPERTY_TITLE= +# NEXT_PUBLIC_NOTION_PROPERTY_STATUS= +# NEXT_PUBLIC_NOTION_PROPERTY_STATUS_PUBLISH= +# NEXT_PUBLIC_NOTION_PROPERTY_STATUS_INVISIBLE= +# NEXT_PUBLIC_NOTION_PROPERTY_SUMMARY= +# NEXT_PUBLIC_NOTION_PROPERTY_SLUG= +# NEXT_PUBLIC_NOTION_PROPERTY_CATEGORY= +# NEXT_PUBLIC_NOTION_PROPERTY_DATE= +# NEXT_PUBLIC_NOTION_PROPERTY_TAGS= +# NEXT_PUBLIC_NOTION_PROPERTY_ICON= +# NEXT_PUBLIC_ENABLE_RSS= +# NEXT_PUBLIC_IS_TAG_COLOR_DISTINGUISHED= +# MAILCHIMP_LIST_ID= +# MAILCHIMP_API_KEY= +# NEXT_PUBLIC_DEBUG= +# ENABLE_CACHE= +# VERCEL_ENV= +# NEXT_PUBLIC_VERSION= From 77c2c5903ad32d4408d9c4c76b83975647bddf0d Mon Sep 17 00:00:00 2001 From: Zhenye Dong Date: Sun, 10 Nov 2024 17:59:59 +0800 Subject: [PATCH 4/7] Add .env.local into .gitignore file for better privacy and practice --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b400f485732..a0811bd90d7 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ yarn-debug.log* yarn-error.log* # local env files -# .env.local # 版本号放在此环境变量中 +.env.local .env.development.local .env.test.local .env.production.local From fe90d94d881141bbd3a7ef9751250ac77d89eb12 Mon Sep 17 00:00:00 2001 From: Zhenye Dong Date: Sun, 10 Nov 2024 18:01:04 +0800 Subject: [PATCH 5/7] docs: improve environment variables documentation --- CONTRIBUTING.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5fffb37aca2..9fde0549768 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,6 +3,7 @@ - [Setup](#setup) - [Creating new themes](#creating-new-themes) - [Adding localizations](#adding-localizations) +- [Environment Variables](#environment-variables) Thanks for considering to contribute! @@ -42,6 +43,19 @@ localization! Follow these steps to add a new localization: 3. Add your language config to [lang.js][lang.js]. 4. [Create a PR][pr] with your localization updates. +## Environment Variables + +NotionNext uses environment variables for configuration. To set up your development environment: + +1. Copy `.env.example` to `.env.local` +2. Fill in the required values in `.env.local` +3. Never commit `.env.local` to version control + +The configuration priority is: +1. Notion Config Table (highest) +2. Environment Variables +3. blog.config.js (lowest) + [fork]: https://github.com/tangly1024/NotionNext/fork [pr]: https://github.com/tangly1024/NotionNext/compare [next.js]: https://github.com/vercel/next.js From b6a6a7215daa0f0fc1a7fa02fcdd6f2ca7db2f9c Mon Sep 17 00:00:00 2001 From: Zhenye Dong Date: Sun, 10 Nov 2024 18:11:21 +0800 Subject: [PATCH 6/7] chore: echo $npm_package_version for dev --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index dff2f46a9f5..6a87045eee4 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "post-build": "next-sitemap --config next-sitemap.config.js", "export": "cross-env EXPORT=true next build && next-sitemap --config next-sitemap.config.js", "bundle-report": "cross-env ANALYZE=true next build", - "build-all-in-dev": "cross-env VERCEL_ENV=production next build" + "build-all-in-dev": "cross-env VERCEL_ENV=production next build", + "version": "echo $npm_package_version" }, "dependencies": { "@clerk/localizations": "^3.0.4", From b927542391b3bbd4cda1f9f52f7e9c84e1c89f05 Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Wed, 13 Nov 2024 11:35:06 +0800 Subject: [PATCH 7/7] =?UTF-8?q?Github=20PR=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/pull_request_template.md | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000000..c9ec6df732a --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,34 @@ +## 已知问题 + +1. (示例)版本号管理不规范 + - 版本号直接写在环境变量中,容易出错 + - 多处维护版本号,可能不一致 + +## 解决方案 + +1. (示例)将版本号管理从 `.env.local` 迁移到 `package.json` + - 统一从 `package.json` 读取版本号 + - 使用 IIFE 优雅处理版本号获取逻辑 + - 保持向后兼容,支持环境变量覆盖 + +## 改动收益 + +1. (示例)更规范的版本管理 + - 统一从 `package.json` 读取 + - 保持与 npm 生态一致 + - 减少人为错误 + +## 具体改动 + +1. (示例)`blog.config.js` + - 移除原有的静态版本号配置 + - 在文件末尾添加动态版本号获取逻辑 + - 保持向后兼容,优先使用环境变量 + - 添加错误处理和默认值 + +## 测试确认 + +- [x] 本地开发环境测试通过 +- [x] 生产环境构建测试通过 +- [x] 版本号正确显示 +- [x] 环境变量配置正常工作