Skip to content

Errors in frontmatter parsing lead to hard-to-diagnose bugs #157

Description

@markjaquith

I had some tags in my frontmatter like this:

---
draft: true
title: My Title
excerpt: My Excerpt
date: 2022-06-22
tags:
  - One
	- Two
---

Since my editor shows tabs as two spaces, I didn't notice that Two was tab-indented.

The way this presents when building will depend on your setup, but for me it was:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'draft' of undefined
at /Users/mark/Sites/example/node_modules/@elderjs/plugin-markdown/index.js:131:32

But my custom slug formatter also uses frontmatter, so before I made the accessing of frontmatter there safe, it was erroring in there.

I think the markdown plugin should detect when frontmatter parsing has resulted in undefined, as otherwise spooky things are gonna happen downstream.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions