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

handle invalid front-matter errors #243

Merged
merged 4 commits into from
Nov 30, 2023
Merged

handle invalid front-matter errors #243

merged 4 commits into from
Nov 30, 2023

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Nov 27, 2023

closes #215

or just wait and see if jonschlinkert/gray-matter#166 is closed?

@Fil Fil requested a review from mbostock November 27, 2023 11:25
@Fil
Copy link
Contributor Author

Fil commented Nov 30, 2023

no answer from upstream yet, let's get this merged?

@Fil Fil marked this pull request as ready for review November 30, 2023 10:28
@Fil Fil requested a review from cinxmo November 30, 2023 10:33
src/markdown.ts Outdated
// https://github.com/jonschlinkert/gray-matter/blob/ce67a86dba419381db0dd01cc84e2d30a1d1e6a5/index.js#L225
// eslint-disable-next-line
// @ts-ignore
matter.clearCache!();
Copy link
Contributor

@cinxmo cinxmo Nov 30, 2023

Choose a reason for hiding this comment

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

is this an undocumented method? I don't see it in the types... (but I see the code in your comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is! I'd prefer for them to fix that bug, but in the meantime it's the best I can do

Copy link
Contributor

Choose a reason for hiding this comment

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

do we really want to throw instead of just logging the error? The rest of the page should render 🤔

Copy link
Member

Choose a reason for hiding this comment

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

You can bypass the cache by passing in empty options:

https://github.com/jonschlinkert/gray-matter/blob/ce67a86dba419381db0dd01cc84e2d30a1d1e6a5/index.js#L44-L47

So let’s do that. Then you won’t need the try catch or clearCache call.

@Fil Fil enabled auto-merge (squash) November 30, 2023 15:21
@Fil Fil merged commit 47fe518 into main Nov 30, 2023
1 check passed
@Fil Fil deleted the fil/front-matter-errors branch November 30, 2023 15:21
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.

uncaught front-matter errors
3 participants