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

feat(v2): broken links detection #3059

Merged
merged 8 commits into from
Jul 21, 2020
Merged

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Jul 14, 2020

Motivation

We should be able to fail fast the build if there are broken links.

We can't necessarily detect external broken links, but at least ensure the internal links always match an existing route.

See also: #3048

Test Plan

TODO


Here's what it shows to the user, at the very end of the build (once all the broken links are collected):

image

It can also be a non-blocking error/log, or just be skipped, according to configuration

For links with anchor, not sure we can do anything easily... but at least the would lead to the correct page

@slorber slorber requested a review from yangshun as a code owner July 14, 2020 17:28
@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Jul 14, 2020
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Jul 14, 2020
@slorber slorber linked an issue Jul 14, 2020 that may be closed by this pull request
@docusaurus-bot
Copy link
Contributor

docusaurus-bot commented Jul 14, 2020

Deploy preview for docusaurus-2 ready!

Built with commit 5af0b3b

https://deploy-preview-3059--docusaurus-2.netlify.app

@slorber slorber marked this pull request as draft July 14, 2020 17:37
@slorber slorber marked this pull request as ready for review July 15, 2020 16:42
@slorber slorber changed the base branch from master to fanny/bootstrap-doc July 15, 2020 16:53
@slorber slorber requested a review from lex111 as a code owner July 15, 2020 16:53
@slorber slorber changed the base branch from fanny/bootstrap-doc to master July 15, 2020 16:53
@slorber
Copy link
Collaborator Author

slorber commented Jul 15, 2020

ready to review @yangshun

opted for throwing an error on broken links by default, with ability to disable it (the error message mentions that config option)

@@ -63,8 +63,6 @@ Strikethrough uses two tildes. ~~Scratch this.~~

[I'm a reference-style link][arbitrary case-insensitive reference text]

[I'm a relative reference to a repository file](../blob/master/LICENSE)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I removed it because this template link is actually broken (this was failing the CI).

It is interpreted as an internal SPA link, and ReactRouter shows the 404:

image

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well then, I am glad this feature already found one broken link :)

# Conflicts:
#	packages/docusaurus/src/client/exports/Link.tsx
#	packages/docusaurus/src/server/configValidation.ts
@slorber slorber merged commit 8ff28e3 into master Jul 21, 2020
@omry
Copy link

omry commented Jul 21, 2020

Awesome! this is great.

@yangshun yangshun deleted the slorber/broken-links-checker branch July 26, 2020 12:36
Vinnl added a commit to inrupt/solid-client-js that referenced this pull request Jul 27, 2020
Docusaurus v2 alpha 59 adds broken link detection
(facebook/docusaurus#3059), but that only
works when linking to the source file.
Vinnl added a commit to inrupt/solid-client-js that referenced this pull request Jul 27, 2020
Docusaurus v2 alpha 59 adds broken link detection
(facebook/docusaurus#3059), but that only
works when linking to the source file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detect internal broken links during build
4 participants