Skip to content

Commit

Permalink
Merge pull request #679 from City-of-Helsinki/UHF-10451_questionnaire…
Browse files Browse the repository at this point in the history
…_heading_in_news_listing

UHF-10451 questionnaire heading in news listing
  • Loading branch information
Arkkimaagi authored Aug 15, 2024
2 parents 196b531 + 12a3d54 commit 69c5ff7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ global-styling:
updating-news-table-of-contents:
js:
dist/js/updatingNewsTableOfContents.min.js: {}
version: 1.0
version: 1.0.1
dependencies:
- core/once
- helfi_toc/table_of_contents
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@
reservedElems.forEach(function (elem) {
Drupal.tableOfContents.reservedIds.push(elem.id);
});
let exclusions = Drupal.tableOfContents.exclusions();

// Add exclusions for the news updates table of contents. NOTICE: The text paragraph is the only one that
// has paragraph as a prefix, so it might look a bit silly compared to the other selectors.
exclusions +=
':not(.components--upper *)' +
':not(.component--remote-video *)' +
':not(.component--paragraph-text *)' +
':not(.component--banner *)' +
':not(.component--image *)' +
':not(.block--news-of-interest *)' +
':not(#helfi-toc-table-of-contents-news-updates *)';
// Instead of targeting all headings on page, lets focus on only news update headings.
// This will generate selector like: .component--news-update h2.component__title, .component--news-update h3.component__title...
const titleComponents = Drupal.tableOfContents.titleComponents('.component__title').map(el => '.component--news-update ' + el);

// Craft table of contents for news item.
once('updating-news-table-of-contents', Drupal.tableOfContents.titleComponents(exclusions).join(','), mainContent)
once('updating-news-table-of-contents', titleComponents.join(','), mainContent)
.forEach(function (content) {

const { nodeName, anchorName} = Drupal.tableOfContents.createTableOfContentElements(content, []);
Expand Down

0 comments on commit 69c5ff7

Please sign in to comment.