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

Check for Broken Links on Build #82

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .config/collections/apiToc.js
Expand Up @@ -18,13 +18,13 @@ function filterElementsWithoutHref(element) {
function removeMDExtension(json) {
json.forEach((element) => {
if (element.href) {
element.href = element.href.replace(/\.md$/, '');
element.href = element.href.replace(/\.md$/, '/');
}

if (element.items) {
element.items.forEach((item) => {
if (item.href) {
item.href = item.href.replace(/\.md$/, '');
item.href = item.href.replace(/\.md$/, '/');
}
});
removeMDExtension(element.items);
Expand Down
21 changes: 21 additions & 0 deletions .config/eleventy.config.events.js
@@ -0,0 +1,21 @@
"use strict";

const linkChecker = require("./events/link-checker");

/** @param {import("@11ty/eleventy").UserConfig} config */
module.exports = function (config) {
config.on("eleventy.after", ({ dir, results, runMode, outputMode }) => {
linkChecker(dir, results, runMode, outputMode, (result) => {
result.errors.forEach((error) => console.log(error));
// Log statistics to console
console.log('')
console.log('Stats:');
console.log(` Internal Links: ${result.internalLinks}`);
console.log(` Internal Anchored Links: ${result.internalAnchoredLinks}`);
console.log(` Internal Parent Links: ${result.internalParentLinks}`);
console.log(` Internal Parent Anchored Links: ${result.internalParentAnchoredLinks}`);
console.log(` External Links: ${result.externalLinks}`);
console.log(` Error Count: ${result.errors.length}`);
});
});
};