Skip to content

Conversation

@luandro
Copy link
Contributor

@luandro luandro commented Oct 11, 2025

Summary

  • emit for empty Notion paragraphs so intentional spacers survive export
  • trim leading/trailing spacer tokens and wire up DocSpacer MDX component
  • cover the transformer with unit tests for empty, nested, and populated paragraphs

Testing

  • bunx eslint scripts/notionClient.ts scripts/notionClient.test.ts src/components/DocSpacer/index.tsx src/theme/MDXComponents/index.tsx --fix
  • bunx eslint scripts/notion-fetch/generateBlocks.ts --fix
  • bunx vitest run scripts/notionClient.test.ts

Fixes #49

@digidem digidem deleted a comment from github-actions bot Oct 11, 2025
@luandro
Copy link
Contributor Author

luandro commented Oct 11, 2025

Summary

  • map empty Notion paragraphs to <DocSpacer /> so intentional spacers survive the export
  • trim spacer tokens off the top/bottom of generated markdown and add an MDX-wired DocSpacer component
  • cover the transformer with unit tests alongside existing Notion client specs

Expected behavior

  • Deliberate blank lines in Notion now render as controlled spacing in MDX/docs pages
  • No stray spacer components appear at the start or end of generated markdown files

QA instructions

  1. Run your usual Notion export pipeline (e.g., bun run notion:fetch) so new content is regenerated.
  2. Inspect a page that previously used intentional blank lines—confirm the generated MDX now contains <DocSpacer /> entries instead of dropped spacing.
  3. Start the docs locally with bun run dev, navigate to that page, and verify the vertical gaps render without extra spacers at the top or bottom.

@luandro luandro closed this Oct 24, 2025
@luandro luandro reopened this Oct 24, 2025
@github-actions
Copy link
Contributor

🚀 Preview Deployment

Your documentation preview is ready!

Preview URL: https://pr-52.comapeo-docs.pages.dev

This preview will update automatically when you push new commits to this PR.


Built with commit 7e2b484

@digidem digidem deleted a comment from github-actions bot Oct 31, 2025
@luandro
Copy link
Contributor Author

luandro commented Oct 31, 2025

Code Review Summary

What This PR Does

This PR implements a feature to preserve intentional spacing (empty paragraphs) from Notion in the generated documentation by:

  • Creating a new <DocSpacer /> React component that renders adjustable vertical space
  • Registering a custom transformer in the Notion-to-Markdown pipeline that detects empty paragraphs
  • Emitting <DocSpacer /> tokens for empty paragraph blocks to survive the export process
  • Trimming leading/trailing spacer tokens to avoid unnecessary whitespace at the start/end of documents
  • Adding comprehensive unit tests for the transformer logic

How It Solves the Issue

The implementation uses a multi-layer approach:

  1. Detection: hasVisibleRichText() function checks if a paragraph contains actual content by examining text, equations, and mentions
  2. Transformation: n2m.setCustomTransformer() intercepts empty paragraphs during Notion-to-Markdown conversion and emits <DocSpacer /> tokens
  3. Cleanup: trimEdgeDocSpacers() removes spacer tokens from document start/end to prevent layout issues
  4. Rendering: The <DocSpacer /> component renders as a styled div with configurable sizes (sm/md/lg)

Potential Issues & Considerations

Strengths:

  • ✅ Well-architected separation of concerns (detection, transformation, rendering)
  • ✅ Comprehensive test coverage (44 lines of new tests) including edge cases (nested blocks, populated blocks)
  • ✅ Proper handling of special content types (equations, mentions)
  • ✅ Size flexibility with sm, md, lg options
  • ✅ Integrates cleanly with Docusaurus via MDXComponents
  • ✅ Non-breaking change - empty paragraphs were already being stripped, this just makes them explicit

Areas to Watch:

  • ⚠️ Usage Pattern: Need to verify how content authors use empty paragraphs in Notion - are they actually intentional spacers or just artifacts? The implementation assumes intentional spacing
  • ⚠️ Default Size: Uses "md" (1rem) as default - should this match the tighter spacing from PR fix(docs): align docs spacing with notion #51/57?
  • ⚠️ MDX Requirement: Depends on MDX support - verified as working but worth noting this is an MDX feature
  • ⚠️ Performance: Minimal impact, but the transformer runs on every paragraph (could be optimized with early returns if needed)

Code Quality:

  • Clean TypeScript with proper typing
  • Good test structure with descriptive test names
  • Follows React best practices (aria-hidden, role=presentation)
  • Proper cleanup logic with edge case handling

Testing:

  • Unit tests cover empty, populated, and nested block scenarios
  • Mocks properly configured for NotionToMarkdown
  • All tests passing

Recommendation:Approve - Solid implementation with good test coverage. The feature enables intentional spacing preservation which improves parity between Notion authoring and published docs.

@digidem digidem deleted a comment from github-actions bot Oct 31, 2025
@luandro luandro marked this pull request as draft November 5, 2025 13:36
@luandro
Copy link
Contributor Author

luandro commented Nov 6, 2025

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ 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".

@luandro
Copy link
Contributor Author

luandro commented Nov 6, 2025

closed in favor of #65

@luandro luandro closed this Nov 6, 2025
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.

empty blocks use to add space between content are being ignored

2 participants