Skip to content

Commit

Permalink
Don't initialize scrollspy when #toc element is missing (#1998)
Browse files Browse the repository at this point in the history
Fixes #1959. Fixes #1889.
  • Loading branch information
gadenbuie committed Jan 6, 2022
1 parent b273ac6 commit f65e81f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

* New Korean (`ko`) translation thanks to @mrchypark and @peremen (#1994).

* Fixed issues that occurred on pages without a table of contents (@gadenbuie, #1998).

# pkgdown 2.0.1

* Fix CRAN failures.
Expand Down
10 changes: 6 additions & 4 deletions inst/BS5/assets/pkgdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
$scope: $("main h2, main h3, main h4, main h5, main h6")
});

$('body').scrollspy({
target: '#toc',
offset: 56 // headroom height
});
if ($('#toc').length) {
$('body').scrollspy({
target: '#toc',
offset: 56 // headroom height
});
}

// Activate popovers
$('[data-bs-toggle="popover"]').popover({
Expand Down

0 comments on commit f65e81f

Please sign in to comment.