-
Notifications
You must be signed in to change notification settings - Fork 306
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
Fix glossary header bug #7371
Fix glossary header bug #7371
Changes from 4 commits
5895a13
24d20a4
f69c7cd
6b3b25b
e9c8b0f
0666775
c993905
52a3476
6b0dea0
f198d3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
nick-mon1 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
{{/* Display a sidebar of glossary terms populated by a json file used on guide pages | ||
nick-mon1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
See example here by clicking on glossary button https://digital.gov/guides/hcd/discovery-concepts/ | ||
nick-mon1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/}} | ||
|
||
|
||
<aside | ||
class="dg-glossary__container" | ||
aria-describedby="dg-glossary__result" | ||
|
@@ -13,7 +18,7 @@ | |
</svg> | ||
</button> | ||
|
||
<h2>Glossary</h2> | ||
<h2 class="dg-glossary__header">Glossary</h2> | ||
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. Added class as a hook for the javascript.
nick-mon1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<label for="dg-glossary__search" class="usa-label">Search for a term:</label> | ||
<input | ||
id="dg-glossary__search" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
// Guide Table of Contents | ||
// Replaces guidenav.js that used Hugo's .TableOfContents with Summary Box component — https://designsystem.digital.gov/components/summary-box/#package | ||
// Get all H2's and create a top of the page Table of Contents if shortcode is used on the markdown page | ||
|
||
/** | ||
* Guide Table of Contents | ||
* Replaces guidenav.js that used Hugo's .TableOfContents with USWDS summary-box — https://designsystem.digital.gov/components/summary-box/#package | ||
* Get all H2's and create a top of the page Table of Contents if shortcode is used on the markdown page | ||
*/ | ||
nick-mon1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// eslint-disable-next-line func-names | ||
(function () { | ||
const guideSummary = document.querySelector(".dg-guide-summary"); | ||
|
||
if (!guideSummary) return; | ||
|
||
const guideSummaryList = guideSummary.querySelector(".usa-list"); | ||
/** | ||
* Return a list of h2's to display in the summary box | ||
* and filter out h2's we do not want to show with the :not selector | ||
*/ | ||
const pageHeaders = document.querySelectorAll( | ||
"h2:not(.usa-summary-box__heading, .dg-guide__content-header-title)" | ||
"h2:not(.usa-summary-box__heading, .dg-guide__content-header-title, .dg-glossary__header)" | ||
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. This query acts as "blacklist" of headers to not in the |
||
); | ||
|
||
/** | ||
* Populate the summary box with bulleted list of links created from the current page's h2's | ||
*/ | ||
function createSummaryBox() { | ||
nick-mon1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const summaryBoxFragment = document.createDocumentFragment(); | ||
pageHeaders.forEach((link) => { | ||
|
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.
Check if
.Parent
page hasglossary
field set. This refers to the root_index.md
in the guide directory.