mirror of https://github.com/twbs/bootstrap.git
				
				
				
			Alternative solution.
Rely on `site.url` which is different for production. In that case do nothing with the search result, otherwise when in development remove our url from it.
This commit is contained in:
		
							parent
							
								
									483e49e3c6
								
							
						
					
					
						commit
						b9577a1cf7
					
				| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
<form class="bd-search d-flex align-items-center">
 | 
			
		||||
  <input type="search" class="form-control" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off" data-baseurl="{{ site.baseurl }}/docs/{{ site.docs_version }}">
 | 
			
		||||
  <input type="search" class="form-control" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off" data-siteurl="{{ site.url }}">
 | 
			
		||||
  <button class="btn btn-link bd-search-docs-toggle d-md-none p-0 ml-3" type="button" data-toggle="collapse" data-target="#bd-docs-nav" aria-controls="bd-docs-nav" aria-expanded="false" aria-label="Toggle docs navigation">
 | 
			
		||||
    {%- include icons/menu.svg width="30" height="30" -%}
 | 
			
		||||
  </button>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -115,8 +115,13 @@
 | 
			
		|||
        },
 | 
			
		||||
        transformData: function (hits) {
 | 
			
		||||
          return hits.map(function (hit) {
 | 
			
		||||
            var baseurl = document.getElementById('search-input').getAttribute('data-baseurl')
 | 
			
		||||
            hit.url = hit.url.replace('https://getbootstrap.com' + baseurl, baseurl)
 | 
			
		||||
            // When in production, return the result as is,
 | 
			
		||||
            // otherwise remove our url from it.
 | 
			
		||||
            var siteurl = document.getElementById('search-input').getAttribute('data-siteurl')
 | 
			
		||||
            var urlRE = /^https?:\/\/getbootstrap\.com/
 | 
			
		||||
 | 
			
		||||
            hit.url = siteurl.match(urlRE) ? hit.url : hit.url.replace(urlRE, '')
 | 
			
		||||
 | 
			
		||||
            return hit
 | 
			
		||||
          })
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue