Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

60 lignes
1.5KB

  1. // NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
  2. // IT'S ALL JUST JUNK FOR OUR DOCS!
  3. // ++++++++++++++++++++++++++++++++++++++++++
  4. (function () {
  5. 'use strict'
  6. if (!window.docsearch) {
  7. return
  8. }
  9. var inputElement = document.getElementById('search-input')
  10. var siteDocsVersion = inputElement.getAttribute('data-docs-version')
  11. function getOrigin() {
  12. var location = window.location
  13. var origin = location.origin
  14. if (!origin) {
  15. var port = location.port ? ':' + location.port : ''
  16. origin = location.protocol + '//' + location.hostname + port
  17. }
  18. return origin
  19. }
  20. window.docsearch({
  21. apiKey: '5990ad008512000bba2cf951ccf0332f',
  22. indexName: 'bootstrap',
  23. inputSelector: '#search-input',
  24. algoliaOptions: {
  25. facetFilters: ['version:' + siteDocsVersion]
  26. },
  27. transformData: function (hits) {
  28. return hits.map(function (hit) {
  29. var currentUrl = getOrigin()
  30. var liveUrl = 'https://getbootstrap.com'
  31. // When in production, return the result as is,
  32. // otherwise remove our url from it.
  33. // eslint-disable-next-line no-negated-condition
  34. hit.url = currentUrl.indexOf(liveUrl) !== -1
  35. ? hit.url
  36. : hit.url.replace(liveUrl, '')
  37. // Prevent jumping to first header
  38. if (hit.anchor === 'content') {
  39. hit.url = hit.url.replace(/#content$/, '')
  40. hit.anchor = null
  41. }
  42. return hit
  43. })
  44. },
  45. // Set debug to `true` if you want to inspect the dropdown
  46. debug: false
  47. })
  48. }())