Skip to content

Commit

Permalink
fix .at is not a function
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Oct 10, 2022
1 parent 77970d6 commit f22b80c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions docs/scripts/reportBrokenLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ const jsFilePathToUrl = (jsFilePath) => {
const file = path.basename(jsFilePath);

const root = folder.slice(jsFilePath.indexOf('/pages') + '/pages'.length);
const suffix = file.split('.').at(-1);
let page = `/${file.slice(0, file.length - 1 - suffix.length)}`;
const suffix = path.extname(file);
let page = `/${file.slice(0, file.length - suffix.length)}`;

if (page === '/index') {
page = '';
Expand Down Expand Up @@ -165,6 +165,11 @@ const parseDocFolder = (folderPath, availableLinks = {}, usedLinks = {}) => {
});
};

const getAnchor = (link) => {
const splittedPath = link.split('/');
return splittedPath[splittedPath.length - 1];
};

// {[url with hash]: true}
const availableLinks = {};

Expand Down Expand Up @@ -196,7 +201,7 @@ Object.keys(usedLinks)
Object.keys(availableLinks)
.filter((link) => getPageUrlFromLink(link) === getPageUrlFromLink(linkKey))
.sort()
.map((link) => link.split('/').at(-1))
.map(getAnchor)
.join('\n'),
);
write('\n\n');
Expand Down

0 comments on commit f22b80c

Please sign in to comment.