Skip to content

Conversation

Yusyuriv
Copy link
Member

@Yusyuriv Yusyuriv commented Mar 29, 2025

This PR adds support for using .mdx files for plugin descriptions and blog posts. This will allow to use complex layouts like using tables while still being able to benefit from Astro's automatic image optimization. This is required to be able to display images in #55.

@Yusyuriv Yusyuriv added the enhancement New feature or request label Mar 29, 2025
@Yusyuriv Yusyuriv self-assigned this Mar 29, 2025
@Yusyuriv Yusyuriv requested a review from onesounds March 29, 2025 01:40
Copy link
Contributor

coderabbitai bot commented Mar 29, 2025

📝 Walkthrough

Walkthrough

The changes integrate MDX support into the Astro project. The Astro configuration now initializes an MDX integration alongside Svelte. A new dependency for MDX is added to the package manifest. The content configuration has been updated to load both .md and .mdx files for several collections. Additionally, the conditional rendering on the plugins page now checks for an alternate content property, allowing greater flexibility when displaying content.

Changes

File(s) Summary of changes
astro.config.mjs, package.json Added MDX integration by including mdx() in the configuration and introducing @astrojs/mdx as a project dependency.
src/content.config.ts Updated file patterns in collection definitions to include both .md and .mdx file types.
src/pages/plugins/[slug]/index.astro Modified the conditional rendering logic to check pluginContent.body in addition to pluginContent.rendered.html when deciding to render the Content component.

Sequence Diagram(s)

sequenceDiagram
    participant A as Astro Server
    participant C as Config Loader
    participant M as MDX Integration
    participant S as Svelte Integration

    A->>C: Load configuration (astro.config.mjs)
    C->>M: Initialize MDX integration
    C->>S: Initialize Svelte integration
    A->>A: Process page requests with MDX & Svelte support
Loading
sequenceDiagram
    participant P as Plugin Page
    participant D as Data Provider
    participant R as Renderer

    P->>D: Request pluginContent
    alt Valid content exists (rendered.html or body)
        D->>R: Provide content details
        R->>P: Render Content component
    else No valid content
        R->>P: Skip Content rendering
    end
Loading

Suggested reviewers

  • jjw24

Poem

I'm a bunny dancing through the code,
Hoping through new paths where MDX is showed.
With markdown magic and a rhythmic beat,
Content now hops with an extra treat.
Bounce on, dear devs, in our joyful mode! 🐰✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd866b5 and a7565dc.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • astro.config.mjs (2 hunks)
  • package.json (1 hunks)
  • src/content.config.ts (3 hunks)
  • src/pages/plugins/[slug]/index.astro (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: gitStream.cm
🔇 Additional comments (7)
package.json (1)

8-8: Properly integrating MDX support through official Astro integration package

The addition of @astrojs/mdx dependency is appropriate for enabling MDX support in the project. This is the official integration package from Astro and will allow for more complex layouts in plugin descriptions and blog posts as intended in the PR objectives.

astro.config.mjs (2)

7-7: Clean import of the MDX integration module

The MDX integration is properly imported following Astro's module pattern, maintaining consistency with the existing imports.


31-31: Correct integration of MDX alongside Svelte

The MDX integration is correctly added to the integrations array alongside the existing Svelte integration. This follows Astro's recommended pattern for adding multiple integrations.

src/pages/plugins/[slug]/index.astro (1)

89-89: Expanded conditional rendering supports both MD and MDX content formats

The conditional check now correctly handles both traditional Markdown (via pluginContent?.rendered?.html) and the new MDX format (via pluginContent?.body). This change ensures a smooth transition between content formats while maintaining the fallback to plugin.description when neither is available.

src/content.config.ts (3)

8-8: Expanded blog collection to support MDX files

The glob pattern has been properly updated to support both .md and .mdx file extensions for the blog collection, maintaining the existing date pattern requirements.


20-20: Enhanced plugins collection to include MDX content

The loader pattern for plugins now correctly accepts both .md and .mdx files while maintaining the same file structure requirements.


39-39: Updated pluginBlog collection to support MDX format

The pattern for plugin blog posts has been expanded to include MDX files while preserving the existing directory structure and date pattern requirements.

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Yusyuriv Yusyuriv merged commit bde8742 into master Mar 30, 2025
1 check passed
@Yusyuriv Yusyuriv deleted the add-support-for-mdx-files branch March 30, 2025 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants