Skip to content

Commit 4996876

Browse files
committed
Add site to search correctly
JAVA-1752
1 parent 3f1657a commit 4996876

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/reference/themes/mongodb/layouts/partials/header/search.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div id="search">
22
<form method="get" action="//www.google.com/search" target="_blank">
33
<input type="text" name="searchQuery" size="20" value="" autocomplete="off" placeholder="Search docs">
4-
<input type="hidden" name="site" value="site:{{.Site.BaseUrl}}">
4+
<input type="hidden" name="site" value="{{.Site.BaseUrl}}">
55
<input type="hidden" name="q" value="">
66
<label for="searchQuery"><i class="fa fa-search fa-1"></i></label>
77
</form>

docs/reference/themes/mongodb/static/js/scripts.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@ function initializeJS() {
1212
});
1313
};
1414

15-
jQuery(document).ready(function(){
15+
jQuery(document).ready(function() {
1616
initializeJS();
1717
jQuery('[data-toggle="tooltip"]').tooltip();
1818
jQuery("body").addClass("jsEnabled");
1919
hljs.initHighlightingOnLoad();
2020
var linkRegex = new RegExp('/' + window.location.host + '/');
2121
jQuery('a').not('[href*="mailto:"]').each(function () {
22-
if ( ! linkRegex.test(this.href) ) {
22+
if (!linkRegex.test(this.href)) {
2323
$(this).attr('target', '_blank');
2424
}
2525
});
2626
jQuery('.body table').addClass('table').addClass('table-striped');
27+
var siteInput = $('#search input[name="site"]');
28+
if (siteInput.val().substring(0, 4) != "http") {
29+
siteInput.attr("value", window.location.hostname + siteInput.val());
30+
}
2731
jQuery("#search form").submit(function() {
28-
$('#search input[name="q"]').attr("value", $('#search input[name="searchQuery"]').val() + ' ' + $('#search input[name="site"]').val());
32+
$('#search input[name="q"]').attr("value", $('#search input[name="searchQuery"]').val() + ' site:' + $('#search input[name="site"]').val());
2933
});
3034
});

0 commit comments

Comments
 (0)