-
-
Notifications
You must be signed in to change notification settings - Fork 622
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
Section splitting in Markdown files #678
Comments
After some consideration, I got a few more ideas on how this could be fleshed out: Frontmatter parsing
Config option to include section data in table of contents generationIn general, most of my personal use cases for sections would also benefit from having sections included in the AST payload for Shape the section object's output to conform to
|
@rbndelrio I wonder if you ever implemented this? I'd be pretty interested in using it. I'm doing something a little similar right now but it is a quite hacky. If not, I could clean up my implementation and maybe contribute it. |
Are there any updates regarding this? I'm trying to make some tabbed content (with each tab showing different content from md) but haven't been able to find a solution I'm happy with. |
Is your feature request related to a problem? Please describe.
The nuxt/content module works really well with article- and editorial-style content via markdown and managing page metadata via yaml/json, but I believe there's a gap in use cases between the two: copy-centric pages with multiple sections.
My personal use case is a website where every page has multiple
<section>
s with a one-off component and body copy per section. The layout can be distilled to a traditional two-column layout:Describe the solution you'd like
I'd like to be able to manage this content from within the same markdown file. On the layout component end, an ideal payload would be an array of objects containing each section's parsed content and its optional frontmatter:
gray-matter
has this feature already, albeit undocumented outside of this example. See additional context.Describe alternatives you've considered
To my knowledge, these are the existing methods to reach a similar result:
Use Vue Components within Markdown
Configure it with JSON/YAML/etc. through frontmatter or a separate file (
~/content/about/sections.yaml
)Split content into multiple files (
~/content/about/section_1.md
)Create a
remark
/rehype
pluginGoing this route is more modular, but I'd argue:
Roll your own configuration with
extendParser
This is actually what I'm doing now but I'm not a fan of how much extra heft and excess processing it's adding to my config. It also results in a substandard file naming convention.
Additional context
Syntax-wise, my example above template's markdown could be written like:
Implementation of
gray-matter
's feature within the parser looks relatively frictionless and could give the user a choice between convention (enabled by default) and configuration (disable or provide a custom parsing function).If we utilize the existing api's return format, the resulting JSON payload could retain the
body
property while adding asections
array. Each section in that array would have the data from its frontmatter and the generated JSON AST:I don't get the impression this would affect the content-fetching methods. However, I haven't thought through how (or whether) these sections can be rendered by the
<nuxt-content>
component.If this sounds like a good feature, I can put together a PR before year's end!
The text was updated successfully, but these errors were encountered: