question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom routes trigger broken links on build

See original GitHub issue

🐛 Bug Report

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io
  • I have read the console error message carefully (if applicable)

Description

I have a custom plugin that adds /api/* routes through actions.addRoute(). This whole flow works great. You can see the code here: https://github.com/milesj/docusaurus-plugin-typedoc-api/blob/master/packages/plugin/src/index.ts#L208

However, when running yarn build, all the /api/* routes fail on broken links, like so:

- On source page path = /api/pipeline/class/Context:
   -> linking to /api
   -> linking to /blog

- On source page path = /api/pipeline/class/Monitor:
   -> linking to /api
   -> linking to /blog

- On source page path = /api/pipeline/class/ParallelPipeline:
   -> linking to /api
   -> linking to /blog

- On source page path = /api/pipeline/class/PooledPipeline:
   -> linking to /api
   -> linking to /blog

- On source page path = /api/pipeline/class/Routine:
   -> linking to /api
   -> linking to /blog

- On source page path = /docs/tutorial-extras/manage-docs-versions:
   -> linking to /api
   -> linking to /blog

- On source page path = /docs/tutorial-extras/translate-your-site:
   -> linking to /api
   -> linking to /blog

I’m not sure how to resolve this or if this is just an oversight.

The routes do appear in the .docusaurus/routes.js file, but not sure if that matters.

Have you read the Contributing Guidelines on issues?

Yes

Steps to reproduce

Use https://new.docusaurus.io to create a CodeSandbox reproducible demo of the bug.

Creating a sandbox of this is too complicated. There are 2 ways to verify this though:

  1. Clone and checkout this PR which attempts to integrate and test the plugin: https://github.com/milesj/boost/pull/157
git clone git@github.com:milesj/boost.git
cd boost
git checkout typedoc
yarn install && yarn run build
cd website
yarn run build
  1. Install the docusaurus-plugin-typedoc-api package and install it in a project: https://www.npmjs.com/package/docusaurus-plugin-typedoc-api

Expected behavior

The broken links check doesn’t fail on custom routes.

Actual behavior

The broken links check fails on custom routes.

I can bypass it for now by changing the onBrokenLinks setting but this isn’t ideal.

Your environment

  • Public source code: https://github.com/milesj/boost/pull/157
  • Public site URL: N/A
  • Docusaurus version used: 2.0.0-beta.4
  • Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): Any node/yarn version
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): MacOS/Ubuntu

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
milesjcommented, Aug 20, 2021

Got it working, thanks for checking.

I have some other things to discuss but I’ll create new issues for them.

0reactions
slorbercommented, Aug 20, 2021

great, looks like it also fixed the 404 issue on https://boostlib.dev/api 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle broken link for static content from assets folder ...
You should be using router-link directive if you want Angular to handle the route. <a [routerLink]="['../../.
Read more >
Routing - Docusaurus
The routes are fully customizable through the slug front matter. ... Docusaurus will only detect broken links when building your site (when ...
Read more >
Broken Link Building: What Is It And Should You Be Doing It?
This article will give you a comprehensive view of what broken link building is, how to implement it, and how it compares to...
Read more >
How To Handle Routing in React Apps with React Router
You can learn about components in How To Create Custom Components in ... add hyperlinks to your project that won't trigger a page...
Read more >
Tutorial: Creating custom route matches - Angular
Tutorial: Creating custom route matcheslink ... The Angular Router supports a powerful matching strategy that you can use to help users navigate your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found