Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search: Support Github pages / http_prefix #196

Merged
merged 1 commit into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/assets/javascripts/_modules/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
var results
var query
var maxSearchEntries = 20
var searchIndexPath

this.start = function start ($element) {
$searchForm = $element.find('form')
Expand All @@ -25,6 +26,7 @@
$searchResults = $searchResultsWrapper.find('.search-results__content')
$searchResultsTitle = $searchResultsWrapper.find('.search-results__title')
$searchHelp = $('#search-help')
searchIndexPath = $element.data('searchIndexPath')

changeSearchAction()
changeSearchLabel()
Expand All @@ -49,7 +51,7 @@
this.downloadSearchIndex = function downloadSearchIndex () {
updateTitle('Loading search results')
$.ajax({
url: '/search.json',
url: searchIndexPath,
cache: true,
method: 'GET',
success: function (data) {
Expand Down
2 changes: 1 addition & 1 deletion lib/source/layouts/_search.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% if config[:tech_docs][:enable_search] %>
<div class="search" data-module="search">
<div class="search" data-module="search" data-search-index-path="<%= search_index_path %>">
<form action="https://www.google.co.uk/search" method="get" role="search" class="search__form govuk-!-margin-bottom-4">
<input type="hidden" name="as_sitesearch" value="<%= config[:tech_docs][:host] %>"/>
<label class="govuk-label search__label" for="search" aria-hidden="true">
Expand Down