Skip to content

feat: Add markdown (.md) support #1224

@minhdqdev

Description

@minhdqdev

Description

I want to enhance the project to support rendering raw Markdown (.md) files.

Why is this better?

Markdown files are less strict than .mdx files because they do not need to render JSX components. Therefore, issues like unclosed HTML tags remain valid in .md files.

Additionally, .md files are more common than .mdx. For example, .md files are supported by many popular static site generators and note-taking apps.

Proposed change in contentlayer.config.ts:

// ...
filePathPattern: 'blog/**/*.{md,mdx}', // old value: blog/**/*.mdx
// ...

This should not break anything for the following reasons:

  1. Same rendering pipeline: It still uses the same contentlayer2 library to process both .mdx and .md files.
  2. Backward compatible: Adding .md support does not change how .mdx files are processed.
  3. Already proven: My website [minhdq.dev](https://minhdq.dev) is currently using both .md and .mdx with contentlayer2 v0.5.5 without issues.

Related issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions