fix searching

This commit is contained in:
polv committed 2020-12-18 09:37:43 +07:00
1 parent 25585aa3da
commit 43edfb60d4
10 files changed
+126 -102

No files matched your search

+2 -2
View File
@@ -58,9 +58,9 @@ export let db: Loki
export let dbPost: Collection<IPost>
export let idx: lunr.Index
let idx: lunr.Index
export async function initLunr () {
export async function getLunr () {
return idx || lunr.Index.load(require('../build/idx.json'))
}
+2 -2
View File
@@ -1,4 +1,4 @@
import { dbPost, idx, initDatabase, initLunr } from './db'
import { dbPost, getLunr, initDatabase } from './db'
export async function doSearch ({
q,
@@ -10,7 +10,7 @@ export async function doSearch ({
page?: number
}) {
await initDatabase()
await initLunr()
const idx = await getLunr()
const perPage = 5
const offset = (page - 1) * perPage