{"id":16160554,"url":"https://github.com/eallion/vercel.og","last_synced_at":"2025-10-08T04:19:10.870Z","repository":{"id":184868510,"uuid":"672601461","full_name":"eallion/vercel.og","owner":"eallion","description":"@vercel/og","archived":false,"fork":false,"pushed_at":"2024-05-14T16:18:15.000Z","size":714,"stargazers_count":3,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-17T06:48:11.031Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://og.eallion.com/api/og?title=","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eallion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-30T16:28:17.000Z","updated_at":"2024-05-14T16:18:19.000Z","dependencies_parsed_at":"2023-07-30T17:51:11.604Z","dependency_job_id":null,"html_url":"https://github.com/eallion/vercel.og","commit_stats":null,"previous_names":["eallion/vercel.og"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eallion%2Fvercel.og","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eallion%2Fvercel.og/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eallion%2Fvercel.og/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eallion%2Fvercel.og/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eallion","download_url":"https://codeload.github.com/eallion/vercel.og/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221718343,"owners_count":16869182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T02:03:27.226Z","updated_at":"2025-10-08T04:19:10.855Z","avatar_url":"https://github.com/eallion.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Open Graph 图像生成服务\n\n这是一个基于 Next.js 构建的 Open Graph（OG）图像生成服务，用于动态生成带有标题的图片卡片，常用于社交媒体分享时的预览图。\n\n## 使用方法\n\n输入 `title` 标题参数即可，其他参数已固化。\n\n\u003e CORS 限制：仅 eallion.com 可引用。\n\n```url\nhttps://api.eallion.com/og?title=你的标题\n```\n\n## 自动字体优化\n\n本项目支持使用 Fontmin 自动优化字体文件，只保留文章标题中实际使用的字符，大大减小字体文件大小。\n\n### 本地开发\n\n1. 在 `.env.local` 文件中设置 Directus API token：\n\n```env\nDIRECTUS_TOKEN=your_directus_api_token_here\n```\n\n2. 运行开发服务器：\n\n```bash\nnpm run dev\n```\n\n### 生产构建\n\n在生产构建过程中，系统会自动执行以下步骤：\n\n```bash\nnpm run build\n```\n\n该命令会依次执行：\n\n1. 从 Directus API 获取文章标题数据\n2. 使用 Fontmin 精简字体文件\n3. 生成背景图片的 base64 数据\n4. 构建 Next.js 应用\n\n### 手动运行字体优化\n\n您也可以手动运行字体优化脚本：\n\n```bash\nnpm run fetch-titles  # 从 Directus API 获取文章标题数据\nnpm run optimize-font # 使用 Fontmin 精简字体文件\n```\n\n如果遇到 API 权限问题，可以使用测试模式：\n\n```bash\nUSE_TEST_MODE=true npm run optimize-font\n```\n\n### 环境变量配置\n\n项目支持从多个来源加载环境变量：\n\n- `.env.local`（优先级最高）\n- `.env`\n- Vercel 环境变量\n- Cloudflare 环境变量\n\n## 部署\n\n### Vercel 部署\n\n1. 在 Vercel 项目设置中添加 `DIRECTUS_TOKEN` 环境变量\n2. 推送代码到 GitHub，Vercel 会自动部署\n\n### Cloudflare Pages 部署\n\n1. 在 Cloudflare Pages 项目设置中添加 `DIRECTUS_TOKEN` 环境变量\n2. 推送代码到 GitHub，Cloudflare Pages 会自动部署\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feallion%2Fvercel.og","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feallion%2Fvercel.og","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feallion%2Fvercel.og/lists"}