Skip to content

Commit

Permalink
Website: improve link-checker to also check URLs from the v2 website
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Oct 5, 2023
1 parent a592165 commit 36aa799
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion website/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ node_modules:
npm install

check-links:
node link-checker/index.js https://bref-website.vercel.app/
node link-checker/index.js https://bref-website.vercel.app
8 changes: 8 additions & 0 deletions website/link-checker/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Command, Option, runExit} from 'clipanion';
import fetch from 'node-fetch';
import { Parser } from "htmlparser2";
import urls from './urls.js';

runExit(class HelloCommand extends Command {
url = Option.String();
Expand All @@ -13,6 +14,13 @@ runExit(class HelloCommand extends Command {
const pageCache = {};
await scan(this.context.stdout, this.url, links, brokenLinks, pageCache);

// Also scan the URLs we whitelisted
for (const chunk of chunkArray(urls)) {
const promises = chunk
.map(link => scan(this.context.stdout, this.url + link, links, brokenLinks, pageCache));
await Promise.all(promises);
}

this.context.stdout.write(`Found ${brokenLinks.size} broken links\n`);
for (const link of brokenLinks) {
this.context.stdout.write(` ${link}\n`);
Expand Down
40 changes: 40 additions & 0 deletions website/link-checker/urls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export default [
// v2 website
'/docs/',
'/docs/news/',
'/docs/news/02-bref-2.0',
'/docs/news/01-bref-1.0',
'/docs/installation',
'/docs/first-steps',
'/docs/runtimes/',
'/docs/runtimes/http',
'/docs/websites',
'/docs/runtimes/console',
'/docs/web-apps/cron',
'/docs/web-apps/local-development',
'/docs/web-apps/docker',
'/docs/frameworks/laravel',
'/docs/frameworks/symfony',
'/docs/runtimes/function',
'/docs/function/handlers',
'/docs/function/local-development',
'/docs/function/cron',
'/docs/deploy',
'/docs/monitoring',
'/docs/environment/serverless-yml',
'/docs/environment/variables',
'/docs/environment/php',
'/docs/environment/storage',
'/docs/environment/logs',
'/docs/environment/database',
'/docs/environment/database-planetscale',
'/docs/environment/custom-domains',
'/docs/environment/performances',
'/docs/upgrading/v2',
'/docs/case-studies',
'/docs/community',
'/docs/installation/aws-keys',
'/docs/environment/database-public',
'/docs/web-apps/local-development.html',
'/docs/web-apps/local-development',
];

0 comments on commit 36aa799

Please sign in to comment.