framework icon indicating copy to clipboard operation
framework copied to clipboard

Links to static files are broken

Open mbostock opened this issue 1 year ago • 1 comments

Consider the following HTML:

<a href="test.png"><img src="test.png"></a>

The img[src] attribute is rewritten as expected, but the a[href] is not, so you get this:

<a href="test.png"><img src="./_file/test.png"></a>

We do rewrite a[href] attribute when there’s also a[download]:

https://github.com/observablehq/cli/blob/205d09b88907899a63fe9f4931715456d4055b6d/src/markdown.ts#L326

We don’t blanketly rewrite a[href] because it’s often used to link to another page, and pages don’t live in _file. But we should be able to tell whether a link is a link to a page or not (because we know how to resolve pages) — and for that matter, we want to normalize and rewrite links to pages anyway (to remove .md and to add .html for non-clean URLs).

mbostock avatar Jan 31 '24 18:01 mbostock

See https://github.com/observablehq/framework/discussions/1328

Fil avatar May 13 '24 10:05 Fil