Markdown Enhancements #424
Replies: 3 comments 19 replies
-
One option that comes to mind around what the configuration would look like is inspired by withastro/astro#5684. There could an enum in the config that contains these values:
This would also bake in the functionality where a user really doesn't want Astro to do any processing on their files. |
Beta Was this translation helpful? Give feedback.
-
Just adding a couple of cents. With regard to link resolution of .md files, my preferred behaviour would be that if I have relative (or absolute) links to files in the static source, then those links would magically be transformed to continue working in the output HTML. I would think Astro knows the original file paths of all files, so it could be some functionality, probably hooked into reMark plugins but with config from Astro, that when processing links, checks them against the graph and grabs the permalink of each and swaps that in. It's probably not straightforward, but it means markdown authored to work on github or in vscode or other tools could be built to html and continue working - otherwise it means links will be broken in one side or the other. Jekyll has a plugin for such functionality with an explanation behind it's reasoning: https://github.com/benbalter/jekyll-relative-links I would like to see this as an option. The purist in me desires the simplicity of a folder of inter-linked markdown files that can be browsed as source (excellent for docs sites where people can browse in GitHub) as well has transformed into a beautiful |
Beta Was this translation helpful? Give feedback.
-
In regards to the "resolving relative assets" part, I've built a rehype plugin to satisfy my want to link between markdown/mdx files to other markdown/mdx files using relative paths. It can be found on Github and NPM. Hopefully it can serve as a stopgap until the functionality is decided to be put into Astro (or can be used as a user-land thing if not). |
Beta Was this translation helpful? Give feedback.
-
Background
I absolutely love the functionality and direction that the Content Collections RFC guides Astro towards. It's a lot of really good baseline work that will hopefully help those integrating content that might not be written alongside an Astro project.
That being said, there can be a lot of friction to a develop new to Astro coming from another platform where they're expecting enhanced markdown functionality out of the box. These can often times be fixed by changing the format of the Markdown, but those are often seen as workarounds and may not be possible to do (such as when a developer's Markdown content is being rendered to another service in parallel and they don't have the flexility to change it).
Current Behaviour
There are already some defaults applied to all markdown parsed by Astro: https://docs.astro.build/en/guides/markdown-content/#configuring-markdown-and-mdx
Missing Behaviour
The below list contains functionality that I'm personally missing. I'm sure there are a lot more and that some are more relevant than others.
.md
included in href for markdown links astro#5682 and Link Resolution inindex.md
files astro#5680)readme.md
being used as an index pageNot all of these may make sense and by introducing more it opens up a can of worms for a potential flood of "well just add xyz feature" for the way Astro parses Markdown.
Current Solutions
Right now you can add in your own remark and rehype plugins as outlined in https://docs.astro.build/en/guides/markdown-content/#markdown-plugins. This can be a daunting task for those who might not be familiar with these tools (how many times did I have to look up the difference between what remark and rehype do today because I kept forgetting? 😅).
There is a very large plugin ecosystem for remark and rehype, but again it can get daunting knowing which plugin to use, how it affects the rendered content, and exposes a whole new level of complexity to a developer. This can cause a lot of DX friction for those moving from another platform where they're used to some of these things happening by default (moving from Docusaurus in my case).
Proposed Solutions
I'd personally prefer either option 1 or 2. It would reduce the friction of developers coming from another platform where they're used to these niceties. This can be a set of "blessed" functionality that I can count on working in Astro and not have to worry about community plugins, updating additional dependencies, wondering how they all interact with each other, etc.
Hopefully there's more feedback on this as I'd love to get the perspective of those in the community who have been around longer than I have; I'd love to hear their feedback!
Oh, and thanks for the amazing Astro project <3
Beta Was this translation helpful? Give feedback.
All reactions