Skip to content

Commit

Permalink
Added jsdocs to document code
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-mon1 committed Mar 7, 2024
1 parent f69c7cd commit 6b3b25b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions themes/digital.gov/layouts/partials/core/glossary.html
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
See example here by clicking on glossary button https://digital.gov/guides/hcd/discovery-concepts/
*/}}


<aside
class="dg-glossary__container"
aria-describedby="dg-glossary__result"
Expand Down
16 changes: 12 additions & 4 deletions themes/digital.gov/src/js/summary-box.js
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
*/
// 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, .dg-glossary__header)"
);

/**
* Populate the summary box with bulleted list of links created from the current page's h2's
*/
function createSummaryBox() {
const summaryBoxFragment = document.createDocumentFragment();
pageHeaders.forEach((link) => {
Expand Down

0 comments on commit 6b3b25b

Please sign in to comment.