observablehq / framework

A static site generator for data apps, dashboards, reports, and more. Observable Framework combines JavaScript on the front-end for interactive graphics with any language on the back-end for data analysis.
https://observablehq.com/framework/
ISC License
2.38k stars 104 forks source link

server-side includes / transclusion #1269

Open Fil opened 4 months ago

Fil commented 4 months ago

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

mbostock commented 4 months ago

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

huw commented 3 months ago

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

![[./Savings Account.csv]]
dleeftink commented 1 month ago

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