Skip to content

Commit

Permalink
Merge branch 'main' of github.com:tangly1024/NotionNext
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylarod committed Jan 5, 2025
2 parents c7d3f4d + 97dd43e commit 18fbb18
Show file tree
Hide file tree
Showing 271 changed files with 9,185 additions and 5,004 deletions.
4 changes: 2 additions & 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.5


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

# 非必须
# NEXT_PUBLIC_VERSION=
# NEXT_PUBLIC_PSEUDO_STATIC=
# NEXT_PUBLIC_REVALIDATE_SECOND=
# NEXT_PUBLIC_THEME=matery
Expand Down Expand Up @@ -174,3 +173,4 @@ NEXT_PUBLIC_VERSION=4.7.5
# ENABLE_CACHE=
# VERCEL_ENV=
# NEXT_PUBLIC_VERSION=
# NEXT_BUILD_STANDALONE=
25 changes: 23 additions & 2 deletions .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 All @@ -20,7 +20,7 @@ module.exports = {
},
ecmaVersion: 12,
sourceType: 'module',
project: './tsconfig.json' // 指定 tsconfig.json 的路径
project: './tsconfig.eslint.json' // 指向新的 ESLint 配置文件
},
plugins: [
'react',
Expand All @@ -42,6 +42,27 @@ module.exports = {
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], // 确保未使用的变量报错
'@typescript-eslint/explicit-function-return-type': 'off' // 关闭强制函数返回类型声明
},
overrides: [
{
files: ['.eslintrc.js'],
parser: null // 避免对 `.eslintrc.js` 文件使用 TypeScript 解析器
},
{
files: ['**/*.js'], // Match all .js files 对js的代码规范检查不那么严格
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-return': 'off'
}
}
],
globals: {
React: true
}
Expand Down
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# These are supported funding model platforms
ko_fi: tangly1024
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
31 changes: 25 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,42 @@
ARG NOTION_PAGE_ID
ARG NEXT_PUBLIC_THEME

# Install dependencies only when needed
FROM node:18-alpine3.18 AS deps
FROM node:18-alpine3.18 AS base

# 1. Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package.json ./
RUN yarn install --frozen-lockfile

# Rebuild the source code only when needed
FROM node:18-alpine3.18 AS builder
# 2. Rebuild the source code only when needed
FROM base AS builder
ARG NOTION_PAGE_ID
ENV NEXT_BUILD_STANDALONE=true

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN yarn build

ENV NODE_ENV production
# 3. Production image, copy all the files and run next
FROM base AS runner
ENV NODE_ENV=production

WORKDIR /app

COPY --from=builder /app/public ./public

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

# 个人仓库把将配置好的.env.local文件放到项目根目录,可自动使用环境变量
# COPY --from=builder /app/.env.local ./

EXPOSE 3000

Expand All @@ -26,4 +45,4 @@ EXPOSE 3000
# Uncomment the following line in case you want to disable telemetry.
# ENV NEXT_TELEMETRY_DISABLED 1

CMD ["yarn", "start"]
CMD ["node", "server.js"]
Loading

0 comments on commit 18fbb18

Please sign in to comment.