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

Add support for frontmatter #390

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jlangeveld
Copy link

@jlangeveld jlangeveld commented Jun 9, 2022

Closes #389

First round - yaml frontmatter is being parsed en re-inserted.
Graymatter supports json out of the box, so I want to work that in too...

@Shinigami92 Shinigami92 added the type: feature request Functionality that introduces a new feature label Jun 9, 2022
@@ -47,6 +47,7 @@
"tsconfig.json"
],
"dependencies": {
"gray-matter": "^4.0.3",
Copy link
Member

Choose a reason for hiding this comment

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

Can we potentially use an optional dependency somehow here? Nearly every user that use my plugin don't use frontmatter. You are the first case in 2-3 years.
Adding a direct dependency would result in not used content for thousands of users.

Copy link
Author

Choose a reason for hiding this comment

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

I might experiment, but gray-matter is a relatively small lib, so I don't know if it's worth the trouble...
What do you think?

j.langeveld@nicagini ~/git/github/jlangeveld/plugin-pug
> du -sh node_modules/gray-matter/
96K     node_modules/gray-matter/

[task/Make_frontmatter-parsing_optional]
j.langeveld@nicagini ~/git/github/jlangeveld/plugin-pug
> du -sh node_modules/
190M    node_modules/

Copy link
Member

Choose a reason for hiding this comment

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

It brings sub-dependencies with it... https://github.com/jonschlinkert/gray-matter/blob/a5726b04f3167fadc764241deb545518c454eb82/package.json#L36-L41
And these have sub-sub-deps and so on.

Copy link
Author

Choose a reason for hiding this comment

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

Oooooohhhhhhhh.... yes.
I should have realised.

j.langeveld@nicagini ~/git/github/gray-matter
> du -sh node_modules/
32M     node_modules/

I'll see what I can do.

tests/frontmatter/unformatted.pug Show resolved Hide resolved
@fisker
Copy link
Member

fisker commented Aug 18, 2022

Maybe copy this https://github.com/prettier/prettier/blob/f2244bdc8621c0a001e3717f595bc8fd8653cce7/src/utils/front-matter/parse.js#L50? Or should Prettier expose it?

@jlangeveld
Copy link
Author

Maybe copy this https://github.com/prettier/prettier/blob/f2244bdc8621c0a001e3717f595bc8fd8653cce7/src/utils/front-matter/parse.js#L50? Or should Prettier expose it?

Sorry for being off the radar, got a bit swamped...
I figured this as a better idea too.
At first just copy it, but ask prettier to expose it.

However, I got hung up trying to convince typescript to accept this javascript code without erorring out on missing type declarations.
Got any tips about that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request Functionality that introduces a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Frontmatter
3 participants