Skip to content
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

feat: add search #2146

Merged
merged 45 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
76ecfb3
feat: add search
Barbapapazes Jul 6, 2023
1af0551
feat: working build and generate
Barbapapazes Jul 6, 2023
341c434
feat: adding integrity
Barbapapazes Jul 6, 2023
d34ff70
feat: pass options to `useFuse` from `useSearch`
Barbapapazes Jul 6, 2023
adf36ff
chore: remove comment
Barbapapazes Jul 6, 2023
53afb31
fix: lazy fetch throw error
Barbapapazes Jul 6, 2023
56c0e2b
feat: add a way to remove tags from index
Barbapapazes Jul 6, 2023
73b8b24
chore: lint
Barbapapazes Jul 6, 2023
eea6faa
feat: add configuration to filter on empty, draft and extensions
Barbapapazes Jul 6, 2023
cc6b5c5
docs: update default extensions value
Barbapapazes Jul 6, 2023
d2e3ae6
feat: use minisearch
Barbapapazes Jul 6, 2023
5c20372
feat: support indexed search and no index
Barbapapazes Jul 6, 2023
b22a2d3
feat: add options to module
Barbapapazes Jul 6, 2023
6aa4254
chore: small adjustment
Barbapapazes Jul 6, 2023
59ee70f
fix: render indexed-search
Barbapapazes Jul 6, 2023
0361bfd
chore: update deps
Barbapapazes Jul 6, 2023
13d8e87
chore: fix type
Barbapapazes Jul 7, 2023
122bf40
Merge branch 'main' into feat/search
Barbapapazes Jul 7, 2023
03640c7
fix: indexed-search format, merge composables, move deps
Barbapapazes Jul 13, 2023
5bf1533
fix: response type for indexed search
Barbapapazes Jul 13, 2023
463145c
feat: add options to ignore drafts, partials and emptry
Barbapapazes Jul 13, 2023
a60ea75
chore: try ssr
Barbapapazes Jul 13, 2023
62e9eb2
chore: apply suggestions from code review
Barbapapazes Jul 13, 2023
122aef4
Merge branch 'main' into feat/search
Barbapapazes Jul 29, 2023
10e4867
refactor: rename useSearch to searchContent
Barbapapazes Sep 15, 2023
1dad206
feat: use ignoreQuery
Barbapapazes Sep 15, 2023
982c7ab
Merge branch 'main' into feat/search
Barbapapazes Sep 15, 2023
475d24e
feat: add an ignore-query
Barbapapazes Sep 15, 2023
f469026
chore: add todo
Barbapapazes Sep 15, 2023
4d9feab
chore: restore nuxt version
Barbapapazes Sep 16, 2023
2fdcad0
refactor: search composables
Barbapapazes Sep 16, 2023
c32ab52
docs: write search
Barbapapazes Sep 16, 2023
7c56a79
refactor: rename some options
Barbapapazes Sep 16, 2023
f10a77e
chore: remove comments
Barbapapazes Sep 16, 2023
278786b
chore: format
Barbapapazes Sep 16, 2023
a816609
Update src/runtime/composables/search.ts
Barbapapazes Sep 16, 2023
340257d
chore: format module imports
Barbapapazes Sep 16, 2023
7e45557
Update docs/content/3.guide/2.displaying/3.search.md
Barbapapazes Sep 17, 2023
bf1f507
Merge branch 'main' into feat/search
Barbapapazes Oct 18, 2023
d5a57b4
refactor: simplify
Barbapapazes Oct 18, 2023
ba25232
chore: lint
Barbapapazes Oct 18, 2023
3ff0c1a
Merge branch 'main' into feat/search
farnabaz Oct 26, 2023
787fca2
chore: move search unders experimentals
farnabaz Oct 27, 2023
4849f32
docs: update
farnabaz Oct 27, 2023
0d76a65
docs: update
farnabaz Oct 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
},
"dependencies": {
"@nuxt/kit": "^3.7.3",
"@vueuse/core": "^10.2.1",
"@vueuse/nuxt": "^10.2.1",
"@nuxtjs/mdc": "^0.1.6",
"@vueuse/head": "^2.0.0",
"consola": "^3.2.3",
Expand All @@ -54,6 +56,7 @@
"listhen": "^1.5.3",
"mdast-util-to-string": "^4.0.0",
"mdurl": "^1.0.1",
"minisearch": "^6.1.0",
"micromark": "^4.0.0",
"micromark-util-sanitize-uri": "^2.0.0",
"micromark-util-types": "^2.0.0",
Expand Down
28 changes: 28 additions & 0 deletions playground/search/components/search.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<script lang="ts" setup>
const search = ref('')

// Usage for non indexed search
// const miniSearch = defineMiniSearchOptions({
// fields: ['title', 'content', 'titles'],
// storeFields: ['title', 'content', 'titles'],
// searchOptions: {
// prefix: true,
// fuzzy: 0.2,
// boost: {
// title: 4,
// content: 2,
// titles: 1
// }
// }
// })
// const result = await searchContent(search, { miniSearch })

// Usage for indexed search
const result = await searchContent(search, { fetch: { lazy: true, server: false } })
</script>

<template>
<input v-model="search">

<pre>{{ result }} </pre>
</template>
3 changes: 3 additions & 0 deletions playground/search/content/_partial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Partial file

This is a partial file.
5 changes: 5 additions & 0 deletions playground/search/content/draft.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
_draft: true
---

# Draft file
Empty file.
45 changes: 45 additions & 0 deletions playground/search/content/javascript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
description: JavaScript, a programming language!
---

# JavaScript

JavaScript (/ˈdʒɑːvΙ™skrΙͺpt/), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2023, 98.7% of websites use JavaScript on the client side for webpage behavior, often incorporating third-party libraries. All major web browsers have a dedicated JavaScript engine to execute the code on users' devices.

Another article.

For more information, see [Wikipedia](https://en.wikipedia.org/wiki/JavaScript).

## Hello World

```javascript
console.log("Hello World!");
```

::alert{type="info"}
This is a JavaScript alert!
::

## History

Hello from history, this is a test!

### Creation

Creation is another test!

### Adoption

## Other usage

### Server-side

This is a section about server-side.

#### Node.js

##### Hello World

### Desktop applications

## See also
9 changes: 9 additions & 0 deletions playground/search/content/php.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
description: PHP, a programming language!
---

# PHP

PHP is a general-purpose scripting language geared towards web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by the PHP Group. PHP was originally an abbreviation of Personal Home Page, but it now stands for the recursive initialism PHP: Hypertext Preprocessor.

For more information, see [Wikipedia](https://en.wikipedia.org/wiki/PHP).
5 changes: 5 additions & 0 deletions playground/search/content/programming.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"languages": [
"javascript"
]
}
17 changes: 17 additions & 0 deletions playground/search/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default defineNuxtConfig({
ssr: false,

extends: ['../shared'],

content: {
search: {
mode: 'full-text',
indexedSearch: true,
ignoreQuery: { _draft: false, _partial: true }
}
},

typescript: {
includeWorkspace: true
}
})
17 changes: 17 additions & 0 deletions playground/search/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script lang="ts" setup>
const open = ref(false)
</script>

<template>
<div>
<h1>Search</h1>

<button @click="open = !open">
{{ open ? 'Close' : 'Open' }} Search
</button>

<Search v-if="open" />

<Search />
</div>
</template>