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

standalone rehype based markdown plugin #1247

Open
thescientist13 opened this issue Jun 21, 2024 · 0 comments
Open

standalone rehype based markdown plugin #1247

thescientist13 opened this issue Jun 21, 2024 · 0 comments
Labels
CLI documentation Greenwood specific docs feature New feature or request Plugins Greenwood Plugins
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented Jun 21, 2024

Summary

Coming out of #955 / #1212, it is now possible for Resource plugins to start opting in to serving pages, like for TypeScript and markdown. With this capability in hand, we should now make the move to moving the markdown capabilities out of the CLI and into its down plugin

While having markdown out of the box is nice, the current dependency list just for markdown right now is quite a lot (7!)
https://github.com/ProjectEvergreen/greenwood/blob/v0.30.0-alpha.2/packages/cli/package.json#L32

"dependencies": {
  "markdown-toc": "^1.2.0",
  "rehype-raw": "^5.0.0",
  "rehype-stringify": "^8.0.0",
  "remark-frontmatter": "^2.0.0",
  "remark-parse": "^8.0.3",
  "remark-rehype": "^7.0.0",
  "unified": "^9.2.0",
},

Plus, since it's not critical (albeit convenient), we shouldn't tax every user on this. Also, this means users can bring their own markdown plugin system as well.

Details

Instead, we should really be promoting the init package and providing the most useful options as part of the wizard, e.g.

  1. Do you want TypeScript?
  2. Do you want markdown?
  3. Etc

Additionally, we should "open" up the configuration so that options from plugins can be forwarded in, since currently our API looks like this:

export default {
  markdown: {
    plugins: [
      "rehype-slug",
      "rehype-autolink-headings",
      "remark-github"
    ],
  },
};

But say if we wanted to configure rehype-autolink-headings to append the link icon, there's currently no way to do this, since we just autoload these plugins.

Going forward, we should support something like this

export default {
  markdown: {
    plugins: [
      "rehype-slug",
      { 
        name: "rehype-autolink-headings",
        "options": { behavior: "append" }
      },
      "remark-github"
    ],
  },
};

I think we'll probably still want to honor frontmatter in the CLI, since as part of #1167 , noticed that frontmatter worked even in HTML, so might be nice to have this shared capability in the CLI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI documentation Greenwood specific docs feature New feature or request Plugins Greenwood Plugins
Projects
Status: 🔖 Ready
Development

No branches or pull requests

1 participant