mirror of
https://github.com/google/pebble.git
synced 2025-05-20 18:34:59 +00:00
Import the pebble dev site into devsite/
This commit is contained in:
parent
3b92768480
commit
527858cf4c
1359 changed files with 265431 additions and 0 deletions
58
devsite/source/assets/js/404.js
Normal file
58
devsite/source/assets/js/404.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
---
|
||||
|
||||
/**
|
||||
* Copyright 2025 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
var $results = $('#js-404-search');
|
||||
|
||||
var search = new Search({
|
||||
appId: '{{ site.algolia_app_id }}',
|
||||
apiKey: '{{ site.algolia_api_key }}',
|
||||
prefix: '{{ site.algolia_prefix }}',
|
||||
options: {
|
||||
hitsPerPage: 2,
|
||||
getRankingInfo: true,
|
||||
distinct: true,
|
||||
removeWordsIfNoResults: 'firstWords',
|
||||
analytics: false
|
||||
}
|
||||
});
|
||||
|
||||
search.on('results', showResults);
|
||||
search.on('error', function (err) {
|
||||
Rollbar.error('404 search error', err);
|
||||
});
|
||||
|
||||
search.search(window.location.pathname.split('/').join(' '));
|
||||
|
||||
function showResults(results) {
|
||||
Object.keys(results).forEach(function (index) {
|
||||
var type = Search.indexes[index];
|
||||
var typeResults = results[index];
|
||||
$results.append('<li style="margin-top: 0.5em;"><strong>' + type.title + '</strong></li>');
|
||||
typeResults.hits.forEach(function (result) {
|
||||
$results.append(buildResult(result));
|
||||
});
|
||||
});
|
||||
$('#js-404-search-intro').show()
|
||||
}
|
||||
|
||||
function buildResult(result) {
|
||||
var $result = $('<li>');
|
||||
$result.append($('<a/>').text(result.title).attr('href', result.url));
|
||||
return $result;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue