-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Algolia DocSearch Integration #201
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a010d64
feat: algolia search - basically migrated
ulivz 330d6f0
fix: enhance style
ulivz 8621a6c
chore: remove debug option
ulivz 0758918
chore: add some comments
ulivz 55826c5
Merge branch 'master' into algolia-docsearch
ulivz b1d2d26
Merge branch 'master' into algolia-docsearch
ulivz 4769b7b
chore: clean up css
ulivz e1d6e88
chore: clean up
ulivz 8177fc6
chore: clean up doc
ulivz 7da0c2a
chore: clean up
ulivz 2dffc4c
Update config.js
yyx990803 ed09b5f
style: limit the max width at mobile side
ulivz 5c3ae19
Merge branch 'algolia-docsearch' of https://github.com/ulivz/vuepress…
ulivz 702d676
feat: support algolia search per locale
ulivz ea8aa21
docs: document algolia option
ulivz a95aa89
docs: update i18n
ulivz 88f7435
chore: address comments
ulivz c150f22
Update README.md
yyx990803 44adcd0
Update config.js
yyx990803 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<template> | ||
<form id="search-form" class="algolia-search-wrapper search-box"> | ||
<input id="algolia-search-input" class="search-query st-default-search-input"> | ||
</form> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['options'], | ||
mounted () { | ||
Promise.all([ | ||
import(/* webpackChunkName: "docsearch" */ 'docsearch.js/dist/cdn/docsearch.min.js'), | ||
import(/* webpackChunkName: "docsearch" */ 'docsearch.js/dist/cdn/docsearch.min.css') | ||
]).then(([docsearch]) => { | ||
docsearch = docsearch.default | ||
docsearch(Object.assign(this.options, { | ||
inputSelector: '#algolia-search-input', | ||
autocompleteOptions: { | ||
openOnFocus: true | ||
} | ||
})) | ||
}) | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="stylus"> | ||
@import './styles/config.styl' | ||
|
||
// TODO align with styles/config.styl | ||
$border = #ddd | ||
$dark = #2c3e50 | ||
$medium = #34495e | ||
$light = #7f8c8d | ||
$green = #42b983 | ||
$border = #dddddd | ||
$codebg = #f8f8f8 | ||
$red = #ff6666 | ||
$info = #1C90F3 | ||
|
||
.algolia-search-wrapper | ||
& > span | ||
vertical-align middle | ||
.algolia-autocomplete | ||
line-height normal | ||
& > input:first-child | ||
display none | ||
.ds-dropdown-menu | ||
background-color #fff | ||
border 1px solid #999 | ||
border-radius 4px | ||
font-size 16px | ||
margin 6px 0 0 | ||
padding 4px | ||
text-align left | ||
&:before | ||
border-color #999 | ||
[class*=ds-dataset-] | ||
border none | ||
padding 0 | ||
.ds-suggestions | ||
margin-top 0 | ||
.ds-suggestion | ||
border-bottom 1px solid $border | ||
.algolia-docsearch-suggestion--highlight | ||
color #2c815b | ||
.algolia-docsearch-suggestion | ||
border-color $border | ||
padding 0 | ||
.algolia-docsearch-suggestion--category-header | ||
padding 5px 10px | ||
margin-top 0 | ||
background $green | ||
color #fff | ||
font-weight 600 | ||
.algolia-docsearch-suggestion--highlight | ||
background rgba(255, 255, 255, 0.6) | ||
.algolia-docsearch-suggestion--wrapper | ||
padding 0 | ||
.algolia-docsearch-suggestion--title | ||
font-weight 600 | ||
margin-bottom 0 | ||
color $dark | ||
.algolia-docsearch-suggestion--subcategory-column | ||
vertical-align top | ||
padding 5px 7px 5px 5px | ||
border-color $border | ||
background #f1f3f5 | ||
&:after | ||
display none | ||
.algolia-docsearch-suggestion--subcategory-column-text | ||
color #555 | ||
.algolia-docsearch-footer | ||
border-color $border | ||
.ds-cursor .algolia-docsearch-suggestion--content | ||
background-color #e7edf3!important | ||
color $dark | ||
|
||
@media (min-width: $MQMobile) | ||
.algolia-search-wrapper | ||
.algolia-autocomplete | ||
.algolia-docsearch-suggestion | ||
.algolia-docsearch-suggestion--subcategory-column | ||
float none | ||
width 150px | ||
min-width 150px | ||
display table-cell | ||
.algolia-docsearch-suggestion--content | ||
float none | ||
display table-cell | ||
width 100% | ||
vertical-align top | ||
.ds-dropdown-menu | ||
min-width 515px!important | ||
|
||
@media (max-width: $MQMobile) | ||
.algolia-search-wrapper | ||
.algolia-docsearch-suggestion--wrapper | ||
padding 5px 7px 5px 5px!important | ||
.algolia-docsearch-suggestion--subcategory-column | ||
padding 0!important | ||
background white!important | ||
.algolia-docsearch-suggestion--subcategory-column-text:after | ||
content " > " | ||
font-size 10px | ||
line-height 14.4px | ||
display inline-block | ||
width 5px | ||
margin -3px 3px 0 | ||
vertical-align middle | ||
|
||
@media (max-width: $MQMobileNarrow) | ||
.ds-dropdown-menu | ||
min-width 320px!important | ||
max-width 320px!important | ||
|
||
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,19 +12,30 @@ | |
</span> | ||
</router-link> | ||
<div class="links"> | ||
<SearchBox v-if="$site.themeConfig.search !== false"/> | ||
<AlgoliaSearchBox v-if="isAlgoliaSearch" :options="$site.themeConfig.algolia"/> | ||
<SearchBox v-if="isSearch"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 可以用 |
||
<NavLinks class="can-hide"/> | ||
</div> | ||
</header> | ||
</template> | ||
|
||
<script> | ||
import SidebarButton from './SidebarButton.vue' | ||
import AlgoliaSearchBox from './AlgoliaSearchBox.vue' | ||
import SearchBox from './SearchBox.vue' | ||
import NavLinks from './NavLinks.vue' | ||
|
||
export default { | ||
components: { SidebarButton, NavLinks, SearchBox } | ||
components: { SidebarButton, NavLinks, SearchBox, AlgoliaSearchBox }, | ||
computed: { | ||
isAlgoliaSearch () { | ||
const { algolia } = this.$site.themeConfig | ||
return algolia && algolia.appId && algolia.apiKey && algolia.indexName | ||
}, | ||
isSearch() { | ||
return !this.isAlgoliaSearch && this.$site.themeConfig.search !== false | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the appId and apiKey be committed as part of the repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your concern, but I have commented at this PR's summary: