Skip to content

feat: Add option to generate configs for static og images#220

Merged
Enter-tainer merged 5 commits intoAfilmory:mainfrom
woolen-sheep:feat-og-image-config-gen
Mar 18, 2026
Merged

feat: Add option to generate configs for static og images#220
Enter-tainer merged 5 commits intoAfilmory:mainfrom
woolen-sheep:feat-og-image-config-gen

Conversation

@woolen-sheep
Copy link
Contributor

@Enter-tainer 提到og-image插件启用太麻烦了,有很多手工成分。
为了开箱即用,增加了生成config的功能,完善了README。

@safedep
Copy link

safedep bot commented Jan 23, 2026

SafeDep Report Summary

Green Malicious Packages Badge Green Vulnerable Packages Badge Green Risky License Badge

Package Details
Package Malware Vulnerability Risky License Report
icon a-sync-waterfall @ 1.0.1
pnpm-lock.yaml
ok icon
ok icon
ok icon
🔗
icon asap @ 2.0.6
pnpm-lock.yaml
ok icon
ok icon
ok icon
🔗
icon chokidar @ 3.6.0
pnpm-lock.yaml
ok icon
ok icon
ok icon
🔗
icon commander @ 5.1.0
pnpm-lock.yaml
ok icon
ok icon
ok icon
🔗
icon nunjucks @ 3.2.4
pnpm-lock.yaml packages/builder/package.json
ok icon
ok icon
ok icon
🔗

This report is generated by SafeDep Github App

@vercel
Copy link

vercel bot commented Jan 23, 2026

@woolen-sheep is attempting to deploy a commit to the innei-dev Team on Vercel.

A member of the Team first needs to authorize it.

@woolen-sheep woolen-sheep force-pushed the feat-og-image-config-gen branch from 827c362 to 53f811d Compare January 23, 2026 13:19
Copy link
Member

@Enter-tainer Enter-tainer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其他地方 LGTM

Copy link
Contributor

@Innei Innei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

整体方案不错,vendor 架构设计合理。有几个建议:

1. 配置路径硬编码问题

const siteConfigPath = options.siteConfigPath
  ? path.resolve(process.cwd(), options.siteConfigPath)
  : path.resolve(process.cwd(), '../../config.json')  // ⚠️ 硬编码相对路径

这个 ../../config.json 假设了固定的项目结构,在 monorepo 或不同目录结构下可能失效。

建议

  • 使用 repoRoot 变量来定位:path.join(repoRoot, 'config.json')
  • 或者让用户必须显式提供 siteConfigPath

2. README 文档不完整

删除了原有的 Cloudflare middleware 示例代码后,新用户可能不清楚:

  • storageURL 应该填什么值?
  • 生成的 middleware 文件在哪里?
  • 如何验证配置是否正确?

建议:补充完整的配置示例和说明,比如:

vendor: {
  type: 'cloudflare-middleware',
  storageURL: 'https://cdn.example.com',  // 你的 OG 图片存储 CDN 地址
  siteConfigPath: './config.json',  // 可选,默认为 repo 根目录的 config.json
}

3. 错误处理建议

if (options.vendor && !vendor) {
  try {
    vendor = createVendor(options.vendor)
  } catch (error) {
    logger.main.error('OG image plugin: failed to initialize vendor config.', error)
    // ⚠️ 继续执行可能不是期望行为
  }
}

vendor 初始化失败时只记录错误,构建会继续。用户可能不会注意到配置错误。

建议

  • 如果 vendor 配置错误,应该抛出异常中断构建
  • 或者在 build 日志中更明显地标记(WARNING 级别)

4. 小优化

.gitignore 中的 functions/ 最好加个注释:

+# og-image-storage plugin generated files
 functions/

代码质量整体良好,主要是文档和健壮性方面的改进建议。LGTM with suggestions 👍

* fix: resolve config.json base on repo root dir
* doc: add more explain about vendor config and generation output
* doc: fix ts code block formatting
@woolen-sheep
Copy link
Contributor Author

Resolved above suggestions in 6525d78

最近加班太多,给搞忘了。。。

@woolen-sheep woolen-sheep requested a review from Innei February 4, 2026 16:26
@woolen-sheep
Copy link
Contributor Author

请问还有什么问题是需要我修改的吗?

@Innei
Copy link
Contributor

Innei commented Mar 15, 2026

冲突接下,直接合了

@woolen-sheep
Copy link
Contributor Author

@Innei resolve了,我点不了合并。

@woolen-sheep woolen-sheep force-pushed the feat-og-image-config-gen branch from 3c77f7d to ef8a473 Compare March 15, 2026 16:12
@Enter-tainer Enter-tainer merged commit 82f687f into Afilmory:main Mar 18, 2026
2 of 4 checks passed
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.

3 participants