Skip to content

Commit

Permalink
Merge branch 'dev' into add-nft-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gcharang committed Feb 29, 2024
2 parents 5cf7168 + 1144a88 commit b819972
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions utils/js/validate_update_internal_links_userpass.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as acorn from "acorn";

import { SKIP, visit } from "unist-util-visit";
import {visitParents} from 'unist-util-visit-parents'

import { constants } from "fs";
import fs from "fs";
Expand Down Expand Up @@ -50,10 +51,12 @@ async function createFileSlugs(filepaths) {
const slugs = [];

let slugify = slugifyWithCounter();
// Visit all heading nodes and collect their values
visit(tree, "heading", (node) => {
const slug = slugify(toString(node));
slugs.push(slug);
// Visit all heading nodes and collect their values while rejecting the ones in DevComment
visitParents(tree, "heading", (node, ancestors) => {
if (!ancestors.some((ancestor) => ancestor.name === "DevComment")) {
const slug = slugify(toString(node));
slugs.push(slug);
}
});
filepathSlugs[filePath] = slugs;
})
Expand Down Expand Up @@ -469,6 +472,10 @@ async function processExternalLink(link, currFilePath) {
`Request timed out when checking the URL ${link} in the file ${currFilePath}`
);
return;
}
else if (err.message.includes("ETIMEDOUT")) {
console.log(`Request timed out when checking the URL ${link} in the file ${currFilePath}`);
return;
} else {
console.error(`Error when checking the URL ${link} in the file ${currFilePath}`)
fs.appendFileSync(manualLinkFile, link + "\n");
Expand Down

0 comments on commit b819972

Please sign in to comment.