-
Notifications
You must be signed in to change notification settings - Fork 0
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
Write JS snippet that generates JSON representation of website menu #1179
Labels
X SMALL
Less than 1 day
Comments
Here's a snippet that gets "99% of the way there." All that's missing is:
// Usage: Copy/paste into a web browser's JavaScript console and press [ENTER].
(function showMenuAsJSON() {
const arr = [];
// For each drop-down menu:
document.querySelectorAll(".header-nav-item").forEach((col, colIdx) => {
// Add a top-level element (having no `items` yet) to the result array, for the top-level link.
const a = col.querySelectorAll("a:first-child")[0];
arr.push({ label: a.title, href: a.href, items: [] });
// For each link in this drop-down menu, add an item to this column's `items` array.
col.querySelectorAll(".header-dropdown > a").forEach((a) => {
arr[colIdx].items.push({ label: a.title, href: a.href });
});
});
console.log(JSON.stringify(arr, null, 2));
})(); This can already be used for "sanity checks." |
Tasks remaining until done:
|
With respect to the second bullet point: I plan to document this snippet in the wiki. |
The snippet has been documented here: https://github.com/microbiomedata/nmdc-server/wiki/Maintaining-the-navigation-menu Closing this ticket as done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is to facilitate future attempts to synchronize the data portal's menu with the website's menu.
This snippet could be copy/pasted into the JavaScript console of a web browser when viewing the website.
Here's an example of an issue where the task was to do that synchronization: #1152
The text was updated successfully, but these errors were encountered: