Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 14, 2024
2 parents 96fba96 + 4fb56d2 commit c0791db
Show file tree
Hide file tree
Showing 54 changed files with 753 additions and 531 deletions.
3 changes: 1 addition & 2 deletions .env.local → .env.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# 环境变量 @see https://www.nextjs.cn/docs/basic-features/environment-variables
NEXT_PUBLIC_VERSION=4.7.7


# 可在此添加环境变量,去掉最左边的(# )注释即可
# Notion页面ID,必须
# NOTION_PAGE_ID=097e5f674880459d8e1b4407758dc4fb

# 非必须
# NEXT_PUBLIC_VERSION=
# NEXT_PUBLIC_PSEUDO_STATIC=
# NEXT_PUBLIC_REVALIDATE_SECOND=
# NEXT_PUBLIC_THEME=matery
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
'plugin:react/jsx-runtime',
'plugin:react/recommended',
'plugin:@next/next/recommended',
'standard',
'next',
'prettier',
'plugin:@typescript-eslint/recommended', // 添加 TypeScript 推荐规则
'plugin:@typescript-eslint/recommended-requiring-type-checking' // 添加需要类型检查的规则
Expand Down
36 changes: 36 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
> 尽量按此模板PR内容,或粘贴相关的ISSUE链接。
## 已知问题

1. (示例)版本号管理不规范
- 版本号直接写在环境变量中,容易出错
- 多处维护版本号,可能不一致

## 解决方案

1. (示例)将版本号管理从 `.env.local` 迁移到 `package.json`
- 统一从 `package.json` 读取版本号
- 使用 IIFE 优雅处理版本号获取逻辑
- 保持向后兼容,支持环境变量覆盖

## 改动收益

1. (示例)更规范的版本管理
- 统一从 `package.json` 读取
- 保持与 npm 生态一致
- 减少人为错误

## 具体改动

1. (示例)`blog.config.js`
- 移除原有的静态版本号配置
- 在文件末尾添加动态版本号获取逻辑
- 保持向后兼容,优先使用环境变量
- 添加错误处理和默认值

## 测试确认

- [x] 本地开发环境测试通过
- [x] 生产环境构建测试通过
- [x] 版本号正确显示
- [x] 环境变量配置正常工作
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# 帮助教程

访问帮助:[NotionNext帮助手册](https://docs.tangly1024.com/)
访问帮助:[NotionNext帮助手册](https://docs.tangly1024.com/)

> 本项目教程为免费、公开资源,仅限个人学习使用。严禁任何个人或组织将本教程用于商业用途,包括但不限于直接售卖、间接收费、或其他变相盈利行为。转载、复制或介绍本教程内容时,须保留作者信息并明确注明来源。
> 本项目仅提供由作者团队授权的付费咨询服务,请注意辨别,谨防诈骗行为。任何未经授权的收费服务均可能存在法律风险。
Notion是一个能让效率暴涨的生产力引擎,可以帮你书写文档、管理笔记,搭建知识库,甚至可以为你规划项目、时间管理、组织团队、提高生产力、还有当前最强大的AI技术加持。

> 如果希望进一步探索Notion的功能,欢迎购买《[Notion笔记从入门到精通进阶课程](https://docs.tangly1024.com/article/notion-tutorial)
# NotionNext
Expand All @@ -27,23 +28,24 @@ Notion是一个能让效率暴涨的生产力引擎,可以帮你书写文档

</p>


中文文档 | [README in English](./README_EN.md)

<hr/>

一个使用 NextJS + Notion API 实现的,部署在 Vercel 上的静态博客系统。为Notion和所有创作者设计。

支持多种部署方案

## 预览效果

在线演示:[https://preview.tangly1024.com/](https://preview.tangly1024.com/) ,点击左下角挂件可以切换主题,没找到喜欢的主题?[贡献](/CONTRIBUTING.md)一个吧~

| Next | Medium | Hexo | Fukasawa |
|--|--|--|--|
| <img src='./docs/theme-next.png' width='300'/> [预览NEXT](https://preview.tangly1024.com/?theme=next) | <img src='./docs/theme-medium.png' width='300'/> [预览MEDIUM](https://preview.tangly1024.com/?theme=medium) | <img src='./docs/theme-hexo.png' width='300'/> [预览HEXO](https://preview.tangly1024.com/?theme=hexo) | <img src='./docs/theme-fukasawa.png' width='300'/> [预览FUKASAWA](https://preview.tangly1024.com/?theme=fukasawa) |
| Next | Medium | Hexo | Fukasawa |
| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| <img src='./docs/theme-next.png' width='300'/> [预览NEXT](https://preview.tangly1024.com/?theme=next) | <img src='./docs/theme-medium.png' width='300'/> [预览MEDIUM](https://preview.tangly1024.com/?theme=medium) | <img src='./docs/theme-hexo.png' width='300'/> [预览HEXO](https://preview.tangly1024.com/?theme=hexo) | <img src='./docs/theme-fukasawa.png' width='300'/> [预览FUKASAWA](https://preview.tangly1024.com/?theme=fukasawa) |

## 致谢

感谢Craig Hart发起的Nobelium项目

<table><tr align="left">
Expand Down Expand Up @@ -189,7 +191,6 @@ Notion是一个能让效率暴涨的生产力引擎,可以帮你书写文档
</tr>
</table>


## 引用技术

- **框架**: [Next.js](https://nextjs.org)
Expand All @@ -198,15 +199,14 @@ Notion是一个能让效率暴涨的生产力引擎,可以帮你书写文档
- **评论**: [Twikoo](https://github.com/imaegoo/twikoo), [Giscus](https://giscus.app/zh-CN), [Gitalk](https://gitalk.github.io), [Cusdis](https://cusdis.com), [Utterances](https://utteranc.es)
- **图标**: [Fontawesome](https://fontawesome.com/v6/icons/)


## 🔗 友情链接

- [Elog](https://github.com/LetTTGACO/elog) Markdown 批量导出工具、开放式跨平台博客解决方案,随意组合写作平台(语雀/Notion/FlowUs/飞书)和博客平台(Hexo/Vitepress/Halo/Confluence/WordPress等)

## License

The MIT License.


## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=tangly1024/NotionNext&type=Date)](https://star-history.com/#tangly1024/NotionNext&Date)
10 changes: 9 additions & 1 deletion blog.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion components/WordCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function WordCount() {
* 更新字数统计和阅读时间
*/
function countWords() {
const articleText = deleteHtmlTag(document.getElementById('notion-article')?.innerHTML)
const articleText = deleteHtmlTag(document.querySelector('#article-wrapper #notion-article')?.innerHTML)
const wordCount = fnGetCpmisWords(articleText)
// 阅读速度 300-500每分钟
document.getElementById('wordCount').innerHTML = wordCount
Expand Down
Loading

0 comments on commit c0791db

Please sign in to comment.