content icon indicating copy to clipboard operation
content copied to clipboard

V2: Handle recursive transclusions in md files

Open ManasMadrecha opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe

With my content folder like this

  • index.md
  • another.md

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

  • Obsidian handles it cleverly by not crashing even when such recursive transclusions are present in 2 md files.
  • So, when encountering such scenarios, the Module should stop the transclusion then and there itself, instead of going round and round.

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

ManasMadrecha avatar Jul 30 '22 16:07 ManasMadrecha

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.

farnabaz avatar Aug 17 '22 13:08 farnabaz

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.

ManasMadrecha avatar Aug 18 '22 08:08 ManasMadrecha