Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dead link errors should show transformed URL #3774

Open
4 tasks done
vincesp opened this issue Apr 10, 2024 · 4 comments
Open
4 tasks done

dead link errors should show transformed URL #3774

vincesp opened this issue Apr 10, 2024 · 4 comments
Labels
docs Improvements or additions to documentation enhancement New feature or request

Comments

@vincesp
Copy link

vincesp commented Apr 10, 2024

Describe the bug

This bug was not present in v1.0.0-rc.24 but is now present in v1.1.0.

  • Create a file with the file extension .crt in the public folder
  • Link to that file from a Markdown file

Current behavior:

  • During page generation, the file extension .html is added after the file extension .crt
  • This results in a dead link
  • Fortunately, the dead link checker picks up the dead link and reports it, which results in a failed build. Unfortunately, the error message is misleading. It prints the original file name "/some-root-ca.crt" which would not be a dead link instead of the corrupted file name "/some-root-ca.crt.html" which is the actual dead link.

Reproduction

https://stackblitz.com/edit/vite-ezwnqb?file=docs%2Fexample.md

  • Run npm run docs:dev
  • Navigate to the Example page
  • There are 2 links
    • The link to the txt file will work
    • The link to the crt file is corrupted, points to /some-root-ca.crt.html instead of /some-root-ca.crt
  • Run npm run docs:build
  • The following error will be displayed:
    (!) Found dead link /some-root-ca.crt in file example.md
    
    If this is expected, you can disable this check via config. Refer: https://vitepress.dev/reference/site-config#ignoredeadlinks
    
    x Build failed in 1.81s
    ✖ building client + server bundles...
    build error:
    Error: [vitepress] 1 dead link(s) found.
        at Object.renderStart (/home/projects/vite-ezwnqb/node_modules/vitepress/dist/node/serve-Csn-CKFx.js:42382:15)
        at eval (/home/projects/vite-ezwnqb/node_modules/rollup/dist/es/shared/node-entry.js:19622:40)
        at async PluginDriver.hookParallel (/home/projects/vite-ezwnqb/node_modules/rollup/dist/es/shared/node-entry.js:19550:9)
        at async Bundle.generate (/home/projects/vite-ezwnqb/node_modules/rollup/dist/es/shared/node-entry.js:17980:13)
        at async eval (/home/projects/vite-ezwnqb/node_modules/rollup/dist/es/shared/node-entry.js:20539:27)
        at async catchUnfinishedHookActions (/home/projects/vite-ezwnqb/node_modules/rollup/dist/es/shared/node-entry.js:19967:16)
    
    Note that the link displayed is not a dead link. The error message does not tell that it in fact tries to link to /some-root-ca.crt.html which does not exist.

Expected behavior

Behavior like in v1.0.0-rc.24:

https://stackblitz.com/edit/vite-5ovzcs?file=package.json

  • Link target is not being changed during page generation
  • No dead link detected during build

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.3 - /usr/local/bin/pnpm
  npmPackages:
    vitepress: latest => 1.1.0

Additional context

No response

Validations

@vincesp vincesp added the bug: pending triage Maybe a bug, waiting for confirmation label Apr 10, 2024
@brc-dd
Copy link
Member

brc-dd commented Apr 10, 2024

add this to top of your config:

process.env.VITE_EXTRA_EXTENSIONS = 'crt'  // comma separated list: 'foo,bar,baz'

regarding error message it probably can be improved 👀

@brc-dd brc-dd closed this as completed Apr 10, 2024
@brc-dd brc-dd reopened this Apr 10, 2024
@vincesp
Copy link
Author

vincesp commented Apr 10, 2024

While downgrading my project to a working version of vitepress, I found out that v1.0.0-rc.39 is the last working version. This bug behavior apparently introduced with 1.0.0-rc.40.

@brc-dd brc-dd removed the bug: pending triage Maybe a bug, waiting for confirmation label Apr 10, 2024
@vincesp
Copy link
Author

vincesp commented Apr 10, 2024

Sorry for the "racing condition." I did not mean to re-open the task, just wanted to document the exact version when the behavior changed.

@vincesp vincesp closed this as completed Apr 10, 2024
@brc-dd
Copy link
Member

brc-dd commented Apr 10, 2024

Ah, no. You didn't. I reopened it because of slightly misleading error message, and missing docs.

@brc-dd brc-dd reopened this Apr 10, 2024
@brc-dd brc-dd changed the title Build adds file extension .html to .crt files, resulting in dead links dead link errors should show transformed URL Apr 10, 2024
@brc-dd brc-dd added enhancement New feature or request docs Improvements or additions to documentation labels Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants