detect broken links#1698
Merged
Merged
Conversation
Merged
Fil
commented
Sep 30, 2024
Contributor
Author
|
The page sizes table we show at the end and the link checker both look similar in that they are "reporters" rather than strictly necessary for the build. I put the link checker at this location because it's fast and if it must break the build it's better to do it sooner. But I'd prefer the happy report to be shown at the end. |
mbostock
reviewed
Sep 30, 2024
mbostock
approved these changes
Sep 30, 2024
Member
There was a problem hiding this comment.
Hooray! Great to have this.
I made some changes. To summarize:
- I encapsulated the code a bit more, reducing the number of local variables in the already quite large and stateful
buildfunction. It would be nice to have separate unit tests forvalidateLinks, perhaps, but it’s pretty simple so not urgent. - I moved the broken link warning to the end where it’s more likely to be seen. If we want to make this a hard error, then we can move it earlier.
- I renamed
linkstolocalLinksto indicate that we’re only extracting (and validating) local links, not all links. - I added encoding as appropriate (
${path}#${encodeURIComponent(id)}). - I skipped validation of
<a href download>since these links are rewritten to point to files. - I disallowed (non-download) links to files, since these links are not rewritten and would be broken.
- I would like to allow links to exported files, but I was lazy and didn’t implement this yet.
- I allowed links to exported modules (which is unlikely but should work).
- I added normalization for trailing
.html(in addition to the existing/index). - I used
parseRelativeUrlinstead of hacking URL withproto:…. - I fixed a longstanding quirk in
resolvePath(and added tests). - I added unit tests for the new
findAssetslogic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently only warning, but we could make it break the build like we do in Plot's documentation. Should this be a build option?
closes #363
closes #1683
(Test by running
yarn docs:build. Merge #1699 to see the happy state.)happy

unhappy
