Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDX with frontmatter reports errors on wrong line #11707

Closed
1 task
nmattia opened this issue Aug 14, 2024 · 1 comment · Fixed by #11717
Closed
1 task

MDX with frontmatter reports errors on wrong line #11707

nmattia opened this issue Aug 14, 2024 · 1 comment · Fixed by #11717
Labels
- P2: nice to have Not breaking anything but nice to have (priority) feat: errors Related to error handling / messages (scope) pkg: mdx Issues pertaining to `@astrojs/mdx` integration

Comments

@nmattia
Copy link
Contributor

nmattia commented Aug 14, 2024

Astro Info

Astro                    v4.13.4
Node                     v20.9.0
System                   macOS (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/sitemap
                         @astrojs/mdx

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When an .mdx page with an error uses a frontmatter, the error is reported on the wrong line (frontmatter is not included):

Unexpected character ! (U+0021) before name, expected a character that can start a name, such as a letter, $, or _ (note: to create a comment in MDX, use {/* text */})

  ...

blog/hello.mdx:2:2

---
title: "hello"
 ^
og_image: /images/hello.jpg
description: "hello"
pubDate: 2024-08-13
draft: true
tags:
  - "hello1"
  - "hello2"
---

<!-- hello! I cause an issue -->

What's the expected result?

Error should be reported on the actual problematic line (12)

Unexpected character ! (U+0021) before name, expected a character that can start a name, such as a letter, $, or _ (note: to create a comment in MDX, use {/* text */})

  ...

blog/hello.mdx:12:2

---
title: "hello"
og_image: /images/hello.jpg
description: "hello"
pubDate: 2024-08-13
draft: true
tags:
  - "hello1"
  - "hello2"
---

<!-- hello! I cause an issue -->
 ^

Link to Minimal Reproducible Example

https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 14, 2024
@Princesseuh Princesseuh added - P2: nice to have Not breaking anything but nice to have (priority) pkg: mdx Issues pertaining to `@astrojs/mdx` integration feat: errors Related to error handling / messages (scope) and removed needs triage Issue needs to be triaged labels Aug 14, 2024
@nmattia
Copy link
Contributor Author

nmattia commented Aug 16, 2024

@bluwy thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: nice to have Not breaking anything but nice to have (priority) feat: errors Related to error handling / messages (scope) pkg: mdx Issues pertaining to `@astrojs/mdx` integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants