6d2221e697ea4a2445202b1c32283610f84585ef
- Author
- Jack Brown <jackbrown@users.noreply.github.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/frontend-search/README.md b/plugins/frontend-search/README.md
2index bf76902fd8fb5a81c01a1a769dab56f102e53b79..ddcb3d72b26d413c984295f304ae3a8906fbec29 100644
3--- a/plugins/frontend-search/README.md
4+++ b/plugins/frontend-search/README.md
5@@ -62,6 +62,10 @@ Available search contexts are:
6
7 If you want to have another context, open an Issue and tell us!
8
9+## Fallback search behaviour
10+
11diff --git a/plugins/frontend-search/frontend-search.plugin.zsh b/plugins/frontend-search/frontend-search.plugin.zsh
12index 87243be1376e91a9fdb5ed9f0f3c48fe2a16f517..ed19280c4a9f40ea8671f4d946a8032ea3699d85 100644
13--- a/plugins/frontend-search/frontend-search.plugin.zsh
14+++ b/plugins/frontend-search/frontend-search.plugin.zsh
15@@ -27,6 +27,17 @@ alias typescript='frontend typescript'
16 alias unheap='frontend unheap'
17 alias vuejs='frontend vuejs'
18
19+function _frontend_fallback() {
20+ local url
21+ if [[ "$FRONTEND_SEARCH_FALLBACK" == duckduckgo ]]; then
22+ url="https://duckduckgo.com/?sites=$1&q="
23+ else
24+ url="https://google.com/search?as_sitesearch=$1&as_q="
25+ fi
26+
27+ echo "$url"
28+}
29+
30 function frontend() {
31 emulate -L zsh
32
33@@ -34,8 +45,8 @@ function frontend() {
34 typeset -A urls
35 urls=(
36 angular 'https://angular.io/?search='
37- angularjs 'https://google.com/search?as_sitesearch=angularjs.org&as_q='
38- bem 'https://google.com/search?as_sitesearch=bem.info&as_q='
39+ angularjs $(_frontend_fallback 'angularjs.org')
40+ bem $(_frontend_fallback 'bem.info')
41 bootsnipp 'https://bootsnipp.com/search?q='
42 bundlephobia 'https://bundlephobia.com/result?p='
43 caniuse 'https://caniuse.com/#search='
44@@ -43,24 +54,24 @@ function frontend() {
45 compassdoc 'http://compass-style.org/search?q='
46 cssflow 'http://www.cssflow.com/search?q='
47 dartlang 'https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart:'
48- emberjs 'https://www.google.com/search?as_sitesearch=emberjs.com/&as_q='
49- flowtype 'https://google.com/search?as_sitesearch=flow.org/en/docs/&as_q='
50+ emberjs $(_frontend_fallback 'emberjs.com/')
51+ flowtype $(_frontend_fallback 'flow.org/en/docs/')
52 fontello 'http://fontello.com/#search='
53 github 'https://github.com/search?q='
54 html5please 'https://html5please.com/#'
55- jestjs 'https://www.google.com/search?as_sitesearch=jestjs.io&as_q='
56+ jestjs $(_frontend_fallback 'jestjs.io')
57 jquery 'https://api.jquery.com/?s='
58 lodash 'https://devdocs.io/lodash/index#'
59 mdn 'https://developer.mozilla.org/search?q='
60- nodejs 'https://www.google.com/search?as_sitesearch=nodejs.org/en/docs/&as_q='
61+ nodejs $(_frontend_fallback 'nodejs.org/en/docs/')
62 npmjs 'https://www.npmjs.com/search?q='
63 qunit 'https://api.qunitjs.com/?s='
64- reactjs 'https://google.com/search?as_sitesearch=facebook.github.io/react&as_q='
65- smacss 'https://google.com/search?as_sitesearch=smacss.com&as_q='
66+ reactjs $(_frontend_fallback 'reactjs.org/')
67+ smacss $(_frontend_fallback 'smacss.com')
68 stackoverflow 'https://stackoverflow.com/search?q='
69- typescript 'https://google.com/search?as_sitesearch=www.typescriptlang.org/docs&as_q='
70+ typescript $(_frontend_fallback 'www.typescriptlang.org/docs')
71 unheap 'http://www.unheap.com/?s='
72- vuejs 'https://www.google.com/search?as_sitesearch=vuejs.org&as_q='
73+ vuejs $(_frontend_fallback 'vuejs.org')
74 )
75
76 # show help for command list