yenly / foamy-nextjs

Basic Foam + NextJS with MDX starter for building a digital garden
65 stars 4 forks source link

Frontmatter support #10

Open krry opened 3 years ago

krry commented 3 years ago

Hiya, and thank you for this template 😸

I'm wondering if it supports/parses frontmatter, or could. Foam now allows us to put tags and such in the frontmatter, which I have started to do as another dimension of interlinkage.

And when I display my notes that contain frontmatter with this template, I see the frontmatter printed as though it were a horizontal line ---, a <p>, then a <h2>. I don't understand why it is parsed this way.

Here is an illustration. This markdown:

---
title: Projects
tags: PARA, zettlekasten, commonplace
timestamp: 2021-03-08 12:03:43
layout: page
---

# Projects

Here we keep teleological endeavors, ones with an end in sight.

becomes this markup:

<hr/>
<p>title: Projects
--
  | tags: PARA, zettlekasten, commonplace
  | timestamp: 2021-03-08 12:03:43</p>
<h2>layout: page</h2>
<h1>Projects</h1>
<p>Here we keep teleological endeavors, ones with an end in sight.</p>

So far I have tried to adding the remark-frontmatter plugin in the next.config.js as you instruct, and in combination with the remark-parse-frontmatter plugin. These seem to have no effect.

I'm stumped. Have you gotten frontmatter parsing to work? Do you have any pointers?

Thanks again. It's so great to be able to use Next and Vercel to publish my second brain.

yenly commented 3 years ago

Hi, @krry! The reason you're not able to add frontmatter is because of the way NextJS had set up their MDX support in /pages. The way to add frontmatter support is similar to the approach in the PR @zomars had sent. I've requested changes to the PR. It could be abandoned by the submitter. I plan to take the PR as a suggestion and work on issue #4 myself. My plate is full at the moment so I won't be able to get to it until next month.

zomars commented 3 years ago

Definitely not abandoned but my plate is also kinda full this month.

krry commented 3 years ago

Ah, thank you for this context! Continuing to attempt to solve this last night I also landed at next-mdx-remote for frontmatter support, and then ran into the nesting issue. I'll of course share any progress I make.

zomars commented 3 years ago

I've updated my PR if you want to take a look @krry. You could modify the Layout and pass the frontmatter data from local mdx files.

krry commented 3 years ago

Aw, rad @zomars, thanks. I have recycled a lot of your PR in my app at this point, checking out the latest.