scantjs / scant

MIT License
14 stars 0 forks source link

Add MDsveX support #6

Closed rdela closed 2 years ago

rdela commented 5 years ago

https://github.com/pngwn/MDsveX

A markdown preprocessor for Svelte components. Basically MDX for Svelte.

Sapper: Add support for custom route file extensions https://github.com/sveltejs/sapper/pull/632

Alternatively, focus efforts on Sapper? https://twitter.com/Rich_Harris/status/1128822261815894016

Although, as I understand it, Scant has a more ambitious scope, wanting to support a plugin system and other things that Sapper does not currently provide. @voldemortensen thoughts?

Cc @pngwn @mrkishi @Conduitry @Rich-Harris

rdela commented 5 years ago

Cc @vedam @arxpoetica @LorbusChris

pngwn commented 5 years ago

I took a quick glance at the MD parsing here and it looks like markdown files are parsed and stored as JSON. This won't work with MDsveX because MDsveX is just a preprocessor, it converts the file into a valid Svelte component that needs to be instantiated like a normal component. I assume Scant creates a little API from which it loads the JSON, I think that would need to be modified for it to work with MDsveX.

All this said, (hopefully) Sapper will have custom route extensions soon and you'll esentially be able to build a static site that also allows md/mdx files as routes file (which will become pages). I don't know about the efficiency trade-offs between loading a blob of JSON and sticking it in a page, and instantiating a new component so I won't comment on that but it will be possible.

rdela commented 5 years ago

Cc @lukeed 🐧.svex

voldemortensen commented 5 years ago

I really like this idea. At first glance the problem to solve would be how to get posts routed without having to configure a route for every single blog post.

rdela commented 5 years ago

Prior art from https://github.com/sveltejs/sapper-template/tree/blog-from-markdown-files (this branch is still on Svelte v2):

"create blog posts from markdown files" commit https://github.com/sveltejs/sapper-template/commit/0fa6c9f7d7ca0933370a985e1178df3754eb8ce7

Comparison against current sapper-template master: https://github.com/sveltejs/sapper-template/compare/blog-from-markdown-files

rdela commented 5 years ago

I just added a commit on a PR I had open on the blog-from-markdown-files branch to bring it up to Svelte v3 and Sapper v0.27.

PR: https://github.com/sveltejs/sapper-template/pull/109 Code: https://github.com/rdela/sapper-template/tree/discordian-blog-from-markdown-files