Skip to content

Comments

fix: disable title extraction when contentHeading === false#3725

Open
farnabaz wants to merge 1 commit intomainfrom
fix/respect-contentheading
Open

fix: disable title extraction when contentHeading === false#3725
farnabaz wants to merge 1 commit intomainfrom
fix/respect-contentheading

Conversation

@farnabaz
Copy link
Member

🔗 Linked issue

resolves #3722

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@vercel
Copy link

vercel bot commented Feb 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
content Ready Ready Preview, Comment Feb 18, 2026 0:22am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 18, 2026

npm i https://pkg.pr.new/@nuxt/content@3725

commit: 175ac8c

@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

This change modifies the Markdown parsing logic in src/utils/content/index.ts to properly respect the markdown.contentHeading: false configuration option. When this option is explicitly set to false, the parser will no longer automatically extract the first heading as title and the first paragraph as description. The change preserves existing behavior for all other cases, where contentHeading defaults to true for non-page collections.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding conditional logic to respect the contentHeading setting by disabling title extraction when contentHeading is false.
Description check ✅ Passed The description references the linked issue #3722 which clearly relates to the changeset's objective of respecting the contentHeading false setting.
Linked Issues check ✅ Passed The code changes directly address issue #3722 by adding conditional logic to disable automatic title/description extraction when contentHeading is explicitly set to false.
Out of Scope Changes check ✅ Passed The changes are narrowly focused on the contentHeading conditional logic and do not introduce unrelated modifications outside the scope of fixing the contentHeading false behavior.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/respect-contentheading

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/utils/content/index.ts (1)

176-178: Prefer ?? to also honour an explicit contentHeading: true on non-page collections.

The current ternary correctly fixes the reported false case but silently ignores an explicit true for non-page collections: true === false is false, so the expression falls through to (!file?.collectionType || file?.collectionType === 'page'), which returns false for 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.

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.

contentHeading: false option is ignored (automatic title/description extraction persists)

1 participant