framework icon indicating copy to clipboard operation
framework copied to clipboard

server-side includes / transclusion

Open Fil opened this issue 1 year ago • 3 comments
trafficstars

If we want bits of HTML or markdown that can be included into a page. (We can do that currently with the header and footer project options, but here we'd want to include one file from the contents of a markdown text.)

Simple solutions are an "include" tag, like Jekyll does https://jekyllrb.com/docs/includes/

The discussion in CommonMark about this topic notes that this should be a domain-specific extension, not a core feature of commonmark. https://talk.commonmark.org/t/transclusion-or-including-sub-documents-for-reuse/270/13

A very nice extension is content blocks by IA-Writer. They can can be HTML or md files, but also csv, images etc. https://github.com/iainc/Markdown-Content-Blocks?tab=readme-ov-file

The spec is basically a line that starts with a /. For example, to include a csv:

/Savings Account.csv 'Recent Transactions'

related: #895

cc: @CobusT

Fil avatar Apr 21 '24 06:04 Fil

Some overlap with JSX/MDX support #971, since the server-side include could just be a component that you import.

mbostock avatar Apr 21 '24 18:04 mbostock

FWIW Obsidian uses a Wikilink syntax which is nice, since it mirrors the image syntax. It looks like:

![[./Savings Account.csv]]

huw avatar May 22 '24 06:05 huw

Also voicing my preference for Obsidian style transclusion (and Wikilinks in general)

dleeftink avatar Jul 23 '24 06:07 dleeftink