-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
🎉 update header nav to new taxonomy #3178
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
} | ||
Comment on lines
+28
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
console.log("✅ All fetches completed") | ||
} | ||
Comment on lines
+6
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
testSiteNavigation() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Invoking |
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" }] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using TypeScript's type annotations for
SiteNavigationStatic
to ensure type safety and clarity in the code.