Skip to content

new#3824

Open
kenchikuliu wants to merge 65 commits intotangly1024:mainfrom
kenchikuliu:main
Open

new#3824
kenchikuliu wants to merge 65 commits intotangly1024:mainfrom
kenchikuliu:main

Conversation

@kenchikuliu
Copy link
Copy Markdown

尽量按此模板PR内容,或粘贴相关的ISSUE链接。

已知问题

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

解决方案

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

改动收益

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

具体改动

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

测试确认

  • 本地开发环境测试通过
  • 生产环境构建测试通过
  • 版本号正确显示
  • 环境变量配置正常工作

kenchikuliu and others added 26 commits August 18, 2025 18:07
- Fix undefined pageCoverThumbnail serialization error in getStaticProps
- Fix undefined href error in Link components
- Change ?? to || operator for image URL handling in getPageProperties
- Add validation for image and href fields in cleanPages function
- Add category mapper utility for Chinese to English conversion
- Update blog configuration with author information
- Add Claude Code documentation (CLAUDE.md, AGENTS.md)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add Chinese/English dual database configuration example
- Document URL access patterns for different languages
- Provide clear setup instructions for multi-language support
Features:
- Add LanguageSwitcher component with dropdown menu
- Support multiple languages with flag emojis
- Auto-detect available locales from router
- Smooth transitions and hover effects
- Dark mode support
- Integrated into heo theme header
- Only shows when multiple languages are configured

Usage:
- Click flag icon to open language menu
- Select language to switch
- Current language is highlighted with checkmark
Features:
- Configure Algolia full-text search integration
- Add detailed configuration comments in .env.example
- Support free tier: 10,000 searches/month, 10,000 records
- Configure App ID, Admin Key, Search-only Key, and Index name

Configuration:
- NEXT_PUBLIC_ALGOLIA_APP_ID: Application ID
- ALGOLIA_ADMIN_APP_KEY: Admin key (backend only, not exposed)
- NEXT_PUBLIC_ALGOLIA_SEARCH_ONLY_APP_KEY: Client search key
- NEXT_PUBLIC_ALGOLIA_INDEX: Database index name

Algolia Dashboard: https://dashboard.algolia.com/account/api-keys/
- Add CHATBASE_ID environment variable documentation to .env.example
- Configure Chatbase chatbot (ID: 5yPXdJr9Pn0D2N5agPLRe)
- Chatbot widget will appear in bottom right corner of website
- Free tier: 20 messages/month, 400,000 characters/bot
- Add useGlobal hook to get current locale
- Add translations for zh-CN, en, and en-US
- Replace hardcoded Chinese text with locale-specific translations
- Contact Channel / Communication Channel now displays in appropriate language
- Add i18n translations for banner titles and categories
- Support for zh-CN, en, and en-US locales
- Dynamic text switching based on current locale
- Update TodayCard subtitle and title with translations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 27, 2026

@kenchikuliu is attempting to deploy a commit to the tangly1024's projects Team on Vercel.

A member of the Team first needs to authorize it.

- Fix double-nested value structure in Notion API response (block, collection, rawMetadata)
- Add defensive null checks in getAllPageIds to prevent crashes
- Improve categoryOptions and tagOptions serialization safety
- Add timeout and retry configuration for Notion API requests
- Update CLAUDE.md with comprehensive project documentation
- Add debugging logs for better troubleshooting

This fixes the issue where Notion blog data was not loading due to incorrect
data structure parsing. All 109 published posts now load correctly.
## 问题描述
Vercel部署在生成/zh-CN/links静态页面时失败,错误:
```
TypeError: Cannot read properties of undefined (reading 'replaceAll')
    at uuidToId (notion-utils/build/index.js:533:31)
    at Block (react-notion-x/build/index.js:2579:66)
```

## 根本原因
在处理Notion数据时,某些页面的block数据不存在或ID为undefined,但代码仍尝试处理这些无效页面:
- `block[id]`返回undefined时,代码继续提取value
- 无效的block ID最终传递给react-notion-x渲染
- 渲染时调用`uuidToId(undefined)`导致崩溃

## 解决方案
在lib/db/getSiteData.js的数据处理循环中添加防御性检查:
1. 跳过ID为undefined的页面
2. 跳过block不存在的页面(`!block[id]`)
3. 跳过value或properties不完整的页面

## 修改文件
- lib/db/getSiteData.js
  - 在处理pageIds循环中添加3层防御性验证
  - 添加警告日志记录跳过的无效页面
  - 确保只有完整有效的页面数据进入渲染流程

## 测试结果
✅ 本地构建成功:npm run build
✅ 所有70个静态页面成功生成
✅ 无uuidToId错误

## 影响范围
- 提高数据处理的健壮性
- 避免因个别无效页面导致整体构建失败
- 不影响正常页面的渲染和功能

相关issue: Vercel deployment ERROR on /zh-CN/links page
## 问题深入分析
之前的修复(commit 4c21689)只解决了数据获取阶段的问题,但Vercel部署仍然失败。
根本原因是:/zh-CN/links页面的blockMap本身包含无效block(blockId存在但value为null/undefined),
这些无效block在渲染阶段被传递给react-notion-x的Block组件,导致uuidToId(undefined)崩溃。

## 问题链条
1. Notion API返回的某些页面blockMap包含无效block
2. getSiteData.js的修复只跳过了无效的page数据,但未清理blockMap内的无效block
3. getPostBlocks.js的convertNotionBlocksToPost处理blockMap时未过滤无效block
4. 无效block传递给NotionPage组件 → react-notion-x渲染 → uuidToId(undefined)崩溃

## 解决方案
在lib/notion/getPostBlocks.js的convertNotionBlocksToPost函数中:
- 在遍历blockMap时添加防御性检查
- 移除blockId为falsy或block.value不存在的无效block
- 添加警告日志记录被移除的无效block
- 确保传递给渲染组件的blockMap只包含有效数据

## 修改文件
- lib/notion/getPostBlocks.js
  - convertNotionBlocksToPost函数添加无效block检查
  - 在slice检查之前过滤无效数据
  - 保证渲染阶段不会遇到undefined的blockId

## 测试结果
✅ 本地构建成功:npm run build
✅ 所有70个静态页面成功生成
✅ 无uuidToId错误
✅ /zh-CN/links页面正常生成

## 影响范围
- 修复Vercel部署在/zh-CN/links页面的渲染崩溃
- 提高blockMap处理的健壮性
- 防止任何包含无效block的页面导致渲染失败
- 不影响正常block的渲染

相关commits: 4c21689 (数据获取阶段修复), 2c91b45 (Notion API双嵌套修复)
kenchikuliu and others added 17 commits February 27, 2026 14:46
问题根因:
- Notion API返回的block对象键名与请求的pageId不一致
- block中实际键: 12700092-b977-817c-9fe7-e28e92e9b996
- 请求的pageId: 2a2f7026-d667-4bd1-9c5a-ec3c94bfd453

修复方案:
- 使用Object.keys(block)[0]获取实际存在的键
- 不再假设block[pageId]一定存在
测试ID: 02ab3b8678004aa69e9e415905ef32a5,en:7c1d570661754c8fbc568e00a01fd70e
目的: 验证默认模板数据库是否可正常访问
根本问题:
- rawMetadata.type是text(页面类型)
- 但页面包含inline database在pageRecordMap.collection中

修复方案:
1. 移除type检查(不再要求collection_view_page类型)
2. 直接从pageRecordMap.collection获取collectionId
3. 检查collection.schema是否存在来验证有效性

这样支持:
- collection_view_page(独立database页面)
- text页面 + inline database(内嵌database)
问题已彻底解决,恢复正常的环境变量读取逻辑
将默认主题从simple改为heo
添加BLOG_FAVICON配置项支持,自动读取Notion数据库的icon作为网站favicon
Generated via Jimeng AI for: attention, jilu, chuhaihegui, deepseekai, deepseekr1local, deepseekr1api

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Match the English tag taxonomy used in the database.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- tail-promo.png: Brand promotional image for article footers
- manus-hero1.png: AI agent illustration for Manus article
- manus-hero2.png: Open-source AI agent comparison illustration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 将默认主题从 heo 改为 medium(更适合技术博客)
- 添加自定义 CSS 样式优化:
  - 增加段落间距(1.5rem)和行高(1.8)
  - 优化标题层级和间距
  - 美化代码块样式(圆角、边框、内边距)
  - 改善行内代码显示
  - 优化列表、引用块、图片样式
  - 添加响应式设计支持
- 提升整体阅读体验
改善博客排版:更换为 medium 主题并添加自定义样式
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant