mirror of
https://github.com/sascha-hemi/pycom-documentation.git
synced 2026-03-21 15:06:31 +01:00
Bing fallback
This commit is contained in:
@@ -91,13 +91,18 @@
|
||||
|
||||
},
|
||||
methods: {
|
||||
handleGoogleError() {
|
||||
const q = 'site:docs.pycom.io ' + this.q;
|
||||
const loc = encodeURI('https://bing.com?q=' + q)
|
||||
window.location = loc
|
||||
},
|
||||
navResult (url) {
|
||||
window.location = url;
|
||||
},
|
||||
fetchResults (kw, start) {
|
||||
if (!start) { start = 1 }
|
||||
let key = "AIzaSyD4-MGytNzTCZpTH6UYk1mfOxZkt74T5MI";
|
||||
let cx = "004592132197158309932:jleutbge8gs";
|
||||
let key = "AIzaSyCDyOKwSjrgE_tkSbO0kbI8Omc6VZMwqA8";
|
||||
let cx = "000185904715529159933:pfyw5o4foii";
|
||||
let url = "https://www.googleapis.com/customsearch/v1";
|
||||
url = url + "?cx=" + cx + "&key=" + key + "&q=" + encodeURI(kw) + "&start=" + start
|
||||
|
||||
@@ -108,11 +113,13 @@
|
||||
// Mmm ... Google result number is varying accross page ....
|
||||
this.pageCount = Math.min(10, Math.trunc(res.data.searchInformation.totalResults/10) + 1)
|
||||
} else {
|
||||
this.handleGoogleError();
|
||||
this.results = null;
|
||||
}
|
||||
}, response => {
|
||||
this.results = null;
|
||||
console.log(response)
|
||||
this.handleGoogleError();
|
||||
this.error = { status: response.error, message: response.text }
|
||||
// ====
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user