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

docs: fix broken links in undici webpage #3807

Merged
merged 2 commits into from
Nov 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
pr feedback
dancastillo committed Nov 8, 2024
commit c1ea7cc23c761dccaeb450528699566551aef063
19 changes: 12 additions & 7 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -38,16 +38,21 @@
// Mimic markedjs/marked behavior just modify href - https://github.com/markedjs/marked/blob/master/src/Renderer.ts#L178-L191
link(href, title, text) {
const originalHref = href;
// Check for /docs/docs/ in the href and remove duplication it if present
href = href.includes('/docs/docs/') ? href.replace('/docs/', '/') : href;

// ignore paths /docs/api/ and /docs/best-practices/ in /docs/docs directory
const ignorePaths = ['/docs/api', '/docs/best-practices'];
if (href.startsWith('./')) {
// Use absolute path (e.g. ./docs/api.md => /docs/api.md) if href starts with ./ (e.g. ./api.md)
href = href.slice(1);
}

// Check for /docs/docs/ in the href and remove duplication it if present
href = href.startsWith('/docs/docs/') ? href.replace('/docs/', '/') : href;

// Check for /docs/ in the href and remove it if present
// Want to ignore paths that are in the ignorePaths array
if (!ignorePaths.some(path => href.includes(path))) {
href = href.includes('/docs/') ? href.replace('/docs/', '/') : href;
if (href.startsWith('/docs/')) {
// ignore paths /docs/api/ and /docs/best-practices/ in /docs/docs directory
if (!/^(\/docs\/(?:api|best-practices))(?:\/|$)/.test(href)) {
href = href.includes('/docs/') ? href.replace('/docs/', '/') : href;
}
}

let target = '';