nuxt / content

The file-based CMS for your Nuxt application, powered by Markdown and Vue components.
https://content.nuxt.com
MIT License
3.13k stars 628 forks source link

V2: Handle recursive transclusions in md files #1396

Open ManasMadrecha opened 2 years ago

ManasMadrecha commented 2 years ago

Is your feature request related to a problem? Please describe

With my content folder like this

If I add <ContentDoc path="/another"></ContentDoc> inside index.md and <ContentDoc path="/"></ContentDoc> inside another.md file, the page crashes and becomes unresponsive.

So, if one file shows other file's content, and vice versa, the page crashes.

Describe the solution you'd like

Content module should intelligently handle such scenarios of recursive transclusions.

The "Transclusion" term being adopted from Obsidian.

Describe alternatives you've considered

Be clever enough not to do so. 😁 But, still these things may happen.

Additional context

Note: The Transclusion works perfectly when it's just 1-way.

farnabaz commented 2 years ago

Thanks for creating issue @ManasMadrecha, You may know that ContentDoc is not designed to use in markdown files, this component is meant to only use in pages to simplify content rendering. Using ContentDoc in a markdown file may break the page's title and meta information.

Also, I believe these things should be taken care of by users, and adding complexity to the module core is not a good choice.

ManasMadrecha commented 2 years ago

Also, I believe these things should be taken care of by users

@farnabaz Yes, that's true. But coming from Obsidian, I was thinking of using a custom-remark plugin (https://github.com/Atinux/content-wind/issues/6#issuecomment-1213299468) to change the ![[... type of transclusions inside md files into md-embed component. And then inside that component check if the transclusion type is of md. If yes, then in that component's template, use ContentDoc component to render the page wholly (or its section/heading).

But yes, it's more of personal issue, rather than Module issue.

And any way, such recursive 2-way transclusion will rarely happen.

And also, even for normal 1-way transclusion I guess, instead of using ContentDoc to display some other md file entirely, I should simply render such md transclusions as special type of a links, which on hover displays Wikipedia style popup.

And any way, even for SEO purpose, having ContentDoc display other page's contents into current page will be like duplicating content on multiple pages. So, better to avoid it.