promote local media assets to file attachments#250
Conversation
|
Nice! In #54 (comment) I started a list of elements we should support. |
006b229 to
848bb4e
Compare
src/markdown.ts
Outdated
| {query: "video source[src]", src: "src"}, | ||
| {query: "audio[src]", src: "src"}, | ||
| {query: "audio source[src]", src: "src"}, | ||
| {query: "link[href]", src: "href"} |
There was a problem hiding this comment.
I purposely didn't add a[href] because we already link to local .md files. See test case:
https://github.com/observablehq/cli/blob/67ebf20b3c1b993f9fc664fd8cd827353d371b65/test/input/build/config/index.md?plain=1#L3-L4
There was a problem hiding this comment.
The question of a[href] highlights a small flaw in our logic.
Here are three cases:
[another page](page)— the page is served from page.md, it's not a file attachment.[view source](file.md)— file.md should be a file attachment<a href="earthquakes.csv" download>download dataset</a>— data.csv should be a file attachment
Currently we base our choice on the tag: in the current approach audio, video, link… are never pointing to pages, and thus indicate a file attachment, and conversely a always indicates a page and never a file attachment.
But shouldn't this be associated to the URL routing instead? If the URL is routed to a md source (or to a static asset #169), it's not a file attachment; otherwise it's a (potential) file attachment.
That new logic could be applied to all the tags. Of course in practice an audio[src] will never be a page (since all pages generate HTML, which are not suitable for audio); but a link[href] can be a page — e.g., <link rel="next"> [ref].
There was a problem hiding this comment.
(Note that this issue will be solved with #257.)
closes #54