fix: disable title extraction when contentHeading === false#3725
fix: disable title extraction when contentHeading === false#3725
contentHeading === false#3725Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
📝 WalkthroughWalkthroughThis change modifies the Markdown parsing logic in Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/utils/content/index.ts (1)
176-178: Prefer??to also honour an explicitcontentHeading: trueon non-page collections.The current ternary correctly fixes the reported
falsecase but silently ignores an explicittruefor non-page collections:true === falseisfalse, so the expression falls through to(!file?.collectionType || file?.collectionType === 'page'), which returnsfalsefor non-page collections regardless of what the user set.Nullish coalescing is the idiomatic fix — it defers to the default only when the option is absent (
null/undefined), and passes any explicit boolean through as-is.♻️ Proposed refactor
- contentHeading: beforeParseCtx.parserOptions?.markdown?.contentHeading === false - ? false - : (!file?.collectionType || file?.collectionType === 'page'), + contentHeading: beforeParseCtx.parserOptions?.markdown?.contentHeading + ?? (!file?.collectionType || file?.collectionType === 'page'),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/utils/content/index.ts` around lines 176 - 178, The expression that computes contentHeading should use nullish coalescing so an explicit true/false in beforeParseCtx.parserOptions?.markdown?.contentHeading is respected rather than overridden by the default; replace the ternary around beforeParseCtx.parserOptions?.markdown?.contentHeading in the contentHeading assignment with the nullish coalescing operator (??) so that contentHeading = beforeParseCtx.parserOptions?.markdown?.contentHeading ?? (!file?.collectionType || file?.collectionType === 'page'), ensuring explicit booleans pass through and the fallback only applies when the option is null/undefined.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/utils/content/index.ts`:
- Around line 176-178: The expression that computes contentHeading should use
nullish coalescing so an explicit true/false in
beforeParseCtx.parserOptions?.markdown?.contentHeading is respected rather than
overridden by the default; replace the ternary around
beforeParseCtx.parserOptions?.markdown?.contentHeading in the contentHeading
assignment with the nullish coalescing operator (??) so that contentHeading =
beforeParseCtx.parserOptions?.markdown?.contentHeading ?? (!file?.collectionType
|| file?.collectionType === 'page'), ensuring explicit booleans pass through and
the fallback only applies when the option is null/undefined.
🔗 Linked issue
resolves #3722
❓ Type of change
📚 Description
📝 Checklist