johnny-mh / devlog

5 stars 1 forks source link

astro-fuse: Unexpected character ! #16

Open bennycode opened 4 months ago

bennycode commented 4 months ago

Thanks for building astro-fuse but when I am having it installed, my development server crashes with the following message:

YAML Exception:

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 /})

It doesn't like my file add-a-window-property-with-typescript.md?astroContentCollectionEntry=true with the following content:

<!-- more -->

It also doesn't like other pragmas such as <!-- prettier-ignore-start --> and {% youtube bRW5r7TK6KM 'video' false %}.

How can these be ignored by the parser?

bennycode commented 4 months ago

I used a workaround by using an HTML extractor (extractContentFromHTML) instead of extracting the content from Markdown.

My current config:

    fuse({
      basedOn: 'output',
      extractContentFromHTML: 'main',
      filter: (pathName) => {
        const isBlog = pathName.startsWith('/blog/');
        const isCategory = pathName.startsWith('/category/');
        const isTag = pathName.startsWith('/tag/');
        return !isBlog && !isCategory && !isTag;
      },
      keys: ['frontmatter.title', 'frontmatter.description'],
    } as AstroFuseConfig)

Unfortunately, this limits my ability to extract meta data from Frontmatter.