You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lychee: avoid problems between --base-url and relative paths
When a HTML file in a subdirectory references a file in the same
subdirectory via a relative path (e.g. Pagefind Playground's
`<link rel="stylesheet" href="./pagefind-playground.css" />` in
`pagefind/playground/index.html`), lychee's `--base-url` option causes
unwanted transformations: It pretends that that file is actually at the
base URL. For example, running with `--base-url
https://dscho.github.io/git-scm.com` will pretend that that CSS is at
https://dscho.github.io/git-scm.com/pagefind-playground.css, skipping
the `pagefind/playground/` altogether.
This is a known issue, and lychee introduced a `--root-dir` option to
accommodate. However, there remain problems, see e.g.
lycheeverse/lychee#1718.
In our concrete case, we cannot easily use `--root-dir` because when we
deploy to forks, the absolute paths have a `/git-scm.com/` prefix yet
that is not the suffix of the absolute path of the `public/` folder!
Even though it is not easily used, it _is_ possible: by constructing a
separate path and adding a symbolic link whose name _is_ `git-scm.com`
and which points to the `public/` directory. Then the parent directory
of that symlink can be used as `--root-dir`.
There is still one caveat: lychee ignores symbolic links when populating
the initial set of files from a given base directory. So let's pass the
path to that symlink, with trailing slash, as the base directory
parameter. That seems to work.
This change is needed because we are about to enable Pagefind's shiny
new Playground, which has an `index.html` file in
`/pagefind/playground/` that references a `.css` in the same directory
via a relative link (which would be mishandled when using `--base-url`).
Signed-off-by: Johannes Schindelin <[email protected]>
0 commit comments