Fixed Docs JS error for Search on non-docs URLS

in utopian-io •  7 years ago  (edited)

Bug Fixes

  • JavaScript errors from embedded Algolia search JS was looking for a #docsearch element that was only on pages using the docs template. Any page being loaded was using the search JavaScript code and non docs pages would throw the console errors.

  • What was the solution?
    Check the page to see if the current page was in the /docs url structure, if so load the search JavaScript code, otherwise do nothing. This solves the issue on non-search pages no longer loading the JavaScript when it wasn't needed, and no longer throws the console errors.



Posted on Utopian.io - Rewarding Open Source Contributors

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Your contribution cannot be approved because it is very small contribution in terms of code, this type of posts may be accepted in future once we have a quality slider but owing to the high reward, I cannot accept it now.

You can contact us on Discord.
[utopian-moderator]

Congratulations @joepferguson! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!