Commit 498ebe4
committed
html-to-pdf: deal with HUGO_RELATIVEURLS=false
When Hugo is told to use absolute URLs, it generates links and image
references that start with a slash, which are misinterpreted when
loading the file into a browser via the file: protocol. Rewrite
those URLs to point to the local filesystem.
To do so, we use the very convenient `page.route()` functionality of
Playwright. Unfortunately, we do not get the "URLs" that start with a
slash, but instead we get bogus `file:///<wrong-path>` URLs. Luckily,
those wrong paths do not start with the absolute path of the `public/`
directory, that's what we can use as tell-tale that an incorrect URL
needs rewriting.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>1 parent 67b1ad4 commit 498ebe4
1 file changed
+16
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
43 | 58 | | |
44 | 59 | | |
45 | 60 | | |
| |||
0 commit comments