Skip to content

Commit

Permalink
update link checker script
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Logan committed Aug 23, 2023
1 parent bdae157 commit ec5447f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tasks/link-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const GITHUB_CREATE_ISSUE_LINK =
const GITHUB_EDIT_LINK = 'https://github.com/aws-amplify/docs/edit/';

const getSitemapUrls = async () => {
let browser = await puppeteer.launch();
let browser = await puppeteer.launch({ headless: 'new' });

const page = await browser.newPage();

Expand Down Expand Up @@ -43,7 +43,7 @@ const getSitemapUrls = async () => {
};

const retrieveLinks = async (siteMapUrls, visitedLinks) => {
let browser = await puppeteer.launch();
let browser = await puppeteer.launch({ headless: 'new' });

const page = await browser.newPage();

Expand All @@ -52,10 +52,11 @@ const retrieveLinks = async (siteMapUrls, visitedLinks) => {
for (let i = 0; i < siteMapUrls.length; i++) {
let url = siteMapUrls[i];

let response = await page.goto(url);
let response = await page.goto(url, { waitUntil: 'domcontentloaded' });
if (response && response.status() && response.status() === 200) {
visitedLinks[url] = true;

console.log(`evaluating ${url}`);
const urlList = await page.evaluate(async (url) => {
let urls = [];
let elements = document.getElementsByTagName('a');
Expand Down

0 comments on commit ec5447f

Please sign in to comment.