Skip to content

Commit

Permalink
Upgrade smooth-scroll to latest version and switch to jsDelivr CDN.
Browse files Browse the repository at this point in the history
The version of `smooth-scroll` we were using was quite old (v7.1.1) compared
to what is now available (v12).  By upgrading to the latest version, and
slightly tweaking the way we instantiate it to support the new construct,
this resolves the issue with anchor tags with periods being incorrectly
escaped.

Fixes #57.
  • Loading branch information
abernix committed Mar 29, 2018
1 parent c742a22 commit 248d0ba
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## vNEXT

* The `versions` property is no longer mandatory in `_config.yml` configurations.
* Fix incorrectly escaped anchor URLs due to bug in ancient version of [`smooth-scroll`](//npm.im/smooth-scroll). [PR #60](https://github.com/meteor/hexo-theme-meteor/pull/60) [Issue #57](https://github.com/meteor/hexo-theme-meteor/issues/57).

## v1.0.3

Expand Down
2 changes: 1 addition & 1 deletion layout/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<!-- End Google Tag Manager (noscript) -->
<% } %>
<%- body %>
<script src="<%= url_for('script/smooth-scroll.min.js', { relative: true }) %>"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/smooth-scroll@12.1.5/dist/js/smooth-scroll.min.js"></script>
<script src="<%= url_for('script/main.js', { relative: true }) %>"></script>
<% if (config.apis && config.apis.docsearch) { %>
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
Expand Down
9 changes: 5 additions & 4 deletions source/script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@

if (h2sWithH3s.length) {
createSubMenu(activeLink.parentNode, h2sWithH3s)
smoothScroll.init({
var scroll = new SmoothScroll('a[href*="#"]', {
speed: 400,
callback: function () {
scrolling = false
offset: 20,
after: function () {
scrolling = false;
}
})
});
}

function createSubMenu (container, headers) {
Expand Down
2 changes: 0 additions & 2 deletions source/script/smooth-scroll.min.js

This file was deleted.

0 comments on commit 248d0ba

Please sign in to comment.