-
-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3178 from owid/nav-updates
🎉 update header nav to new taxonomy
- Loading branch information
Showing
5 changed files
with
293 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Test all the slugs in the SiteNavigationStatic object and makes sure | ||
// https://ourworldindata.org/{slug} returns a 200 | ||
|
||
import { SiteNavigationStatic } from "../../site/SiteNavigation.js" | ||
|
||
const testSiteNavigation = async () => { | ||
const slugs = SiteNavigationStatic.categories | ||
.map((category) => { | ||
const categorySlugs = category.entries | ||
.map((entry) => entry.slug) | ||
.concat( | ||
(category.subcategories?.length && | ||
category.subcategories.flatMap((subcategory) => | ||
subcategory.entries.map((entry) => entry.slug) | ||
)) || | ||
[] | ||
) | ||
return categorySlugs | ||
}) | ||
.flat() | ||
|
||
let promises = slugs.map((slug) => { | ||
return fetch(`https://ourworldindata.org/${slug}`, { | ||
method: "HEAD", | ||
}) | ||
}) | ||
|
||
const responses: Response[] = await Promise.all(promises) | ||
if (responses.some((response) => !response.ok)) { | ||
console.error( | ||
"❌ One or more fetches failed: ", | ||
responses | ||
.filter((response) => !response.ok) | ||
.map((response) => response.url) | ||
) | ||
return | ||
} | ||
console.log("✅ All fetches completed") | ||
} | ||
|
||
testSiteNavigation() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../tsconfigs/tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "../../itsJustJavascript/devTools/navigationTest", | ||
"rootDir": "." | ||
}, | ||
"references": [{ "path": "../../site" }] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.