-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* docs: added full text search component FullTextSearch.vue and search field in default.vue (#197) * docs: code formatting(#197) * Revert "docs: code formatting(#197)" This reverts commit 0c60fad. * Revert "docs: added full text search component FullTextSearch.vue and search field in default.vue (#197)" This reverts commit 3146c18. * chore(#197): remove home from horizontal menu * feat(#197): add search component to sidebar * chore(#197): add .nvmrc * chore(#197): add deep search * chore(#197): fixed modules search link * chore(#197): update search Co-authored-by: Dave Connerth <captaindav@gmail.com>
- Loading branch information
1 parent
5c01b00
commit 56b3966
Showing
5 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
v16.14.2 |
This file contains 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 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 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,86 @@ | ||
<template> | ||
<ul class="mb-5 menu"> | ||
<li slot="title" class="menu-title"> | ||
<span>Search</span> | ||
</li> | ||
<li> | ||
<div class="form-control"> | ||
<input | ||
v-model="model" | ||
type="text" | ||
placeholder="" | ||
class="input input-bordered" | ||
> | ||
</div> | ||
</li> | ||
|
||
<!-- Results --> | ||
<template v-if="isResults"> | ||
<template v-for="type of Object.keys(results)"> | ||
<template v-if="results[type].length"> | ||
<li :key="type" /> | ||
<li | ||
v-for="item of results[type]" | ||
:key="item.id" | ||
> | ||
<NuxtLink | ||
class="rounded-btn" | ||
:to="item.path" | ||
> | ||
<component | ||
:is="`app-icon-${type}`" | ||
class="inline-block w-5 h-5 mr-2 stroke-current text-gray-400" | ||
/> | ||
{{ item.title }} | ||
</NuxtLink> | ||
</li> | ||
</template> | ||
</template> | ||
</template> | ||
|
||
<!-- No results --> | ||
<li v-else-if="model && !isResults"> | ||
<span class="rounded-btn">No results</span> | ||
</li> | ||
</ul> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
data: () => ({ | ||
model: '', | ||
results: { | ||
api: [], | ||
guide: [], | ||
modules: [], | ||
}, | ||
}), | ||
computed: { | ||
isResults: ({ results }) => results.api.length || results.guide.length || results.modules.length | ||
}, | ||
watch: { | ||
async model() { | ||
// Empty results if model is empty. | ||
if (!this.model) { | ||
this.results = { | ||
api: [], | ||
guide: [], | ||
modules: [], | ||
} | ||
return | ||
} | ||
// Search all available data. | ||
for (const type of ['api', 'guide', 'modules']) { | ||
const results = await this.$content(type, { deep: true }) | ||
.search(this.model) | ||
.limit(3) | ||
.fetch() | ||
this.results[type] = results | ||
} | ||
} | ||
} | ||
} | ||
</script> |
This file contains 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