vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
13.32k stars 2.15k forks source link

Markdown absolute links to plaintext files in public directory attempts to link as HTML #4208

Closed lifehackerhansol closed 2 months ago

lifehackerhansol commented 2 months ago

Describe the bug

If there is a plaintext file in public directory, and the file extension is unrecognized (i.e. .txt files are recognized, but .ini, or any random combination of file extensions, are not), the build system is attempting to convert the links to append .html to it. This causes the link to 404.

Reproduction

NOTE: this reproduces a scenario in the testing environment. docs:build doesn't even run because, as a result of the below generation, the link is being treated as dead.

Add this to /public/hello.ini:

[helloworld]

And then have any page link to it like so:

[download hello.ini](/hello.ini)

And it will generate:

<a href="/hello.ini.html">download hello.ini</a>

Expected behavior

The docs seem to suggest that files in the public directory will be copied as-is to the output directory; the same logic should apply to links. That is to say, there should be no .html suffix in the href and either the download or the browser opening the resulting file in plaintext should proceed.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
    Memory: 4.95 GB / 31.92 GB
  Binaries:
    Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.86)
    Internet Explorer: 11.0.19041.4355
  npmPackages:
    vitepress: ^1.3.4 => 1.3.4

Additional context

No response

Validations

brc-dd commented 2 months ago
process.env.VITE_EXTRA_EXTENSIONS = 'ini' // additional values should be comma separated without any spaces - `ini,foo,bar`

Put this on top of your .vitepress config file.

3852 is open about docs.