[codex] Share redirect URL normalization - #209
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthrough
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@codex review |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
estrilda | aa15b4d | Commit Preview URL Branch Preview URL |
Jun 23 2026, 04:53 AM |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2b711c7107
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| return lines; | ||
| return meta.draft !== true; |
There was a problem hiding this comment.
Match Astro's draft filtering when counting posts
When a post uses quoted frontmatter such as draft: "true", gray-matter returns a string; extractMetadata passes that through, while the Astro content loader drops drafts with a truthy check (apps/astro-blog/src/lib/content.ts line 238). This strict comparison counts that post as published, so _redirects can emit root pagination redirects for pages Astro does not generate once drafts affect the 12-post boundary. Use the same truthy draft check here.
Useful? React with 👍 / 👎.
Summary
Closes #203.
@estrivault/content-processormetadata extraction, which usesgray-matterinternally._redirectsrules from per-post/per-tag/per-category enumeration into placeholder-based canonical rules.Redirect behavior
The generated
_redirectsfile now has 34 lines instead of 720. This is an intentional behavior change: category and tag archive trailing-slash redirects are preserved with placeholder rules, while post/note document proxy and trailing-slash redirects are generalized by slug.This means generic rules may match non-existent slugs too; those should still resolve to 404 when the backing asset is absent.
Validation
pnpm --filter astro-blog run generate:redirectspnpm type-checkgit diff --checkgit diff --find-renames -- content/blogURL正規化ロジックの共有化: アプリケーションのスラッグ生成・タグ/カテゴリ正規化処理を、
url-segments.mjsの共通ヘルパーに統一し、リダイレクト生成スクリプトで同じロジックを再利用できるようにした(コード重複の排除と保守性向上)リダイレクト定義の簡略化:
_redirectsファイルを個別スラッグ列挙型から、プレースホルダベースの宣言型ルール(:category、:tag、:slugなど)に変更し、720行から34行に削減した(保守性向上・可読性改善)Frontmatter解析の置き換え: カスタムフロントマター解析をメタデータ抽出用の標準ヘルパーに統一し、記事・メモのスラッグ生成を共通の
getSlugFromMarkdownPathで一元化した(実装の統一・冗長性排除)アーカイブページング: リダイレクト生成時に公開済み記事数に基づいてアーカイブのページ数を動的に計算し、固定的な個別ルールではなく計算ベースのプレースホルダルールで対応するようにした(スケーラビリティ向上・自動化)