make sure it can build
This commit is contained in:
1 parent
f527b810b6
commit
25585aa3da
3 files changed
+9
-22
No files matched your search
@@ -1,6 +1,5 @@
|
||||
/* eslint-disable import/no-mutable-exports */
|
||||
|
||||
import idxJson from '~/build/idx.json'
|
||||
import Loki, { Collection } from 'lokijs'
|
||||
import lunr from 'lunr'
|
||||
import * as z from 'zod'
|
||||
@@ -42,22 +41,7 @@ export const zPost = z
|
||||
})
|
||||
.merge(zMatterSerialized)
|
||||
|
||||
export type IPost = z.infer<typeof zPost> & {
|
||||
path: string
|
||||
title: string
|
||||
content: string
|
||||
excerptHtml: string
|
||||
contentHtml: string
|
||||
}
|
||||
|
||||
export type IPostTeaser = {
|
||||
path: string
|
||||
date?: number
|
||||
title: string
|
||||
image?: string
|
||||
content: string
|
||||
excerptHtml: string
|
||||
}
|
||||
export type IPost = z.infer<typeof zPost>
|
||||
|
||||
export interface IPostSearch {
|
||||
path: string
|
||||
@@ -76,13 +60,15 @@ export let dbPost: Collection<IPost>
|
||||
|
||||
export let idx: lunr.Index
|
||||
|
||||
export async function initLunr () {
|
||||
return idx || lunr.Index.load(require('../build/idx.json'))
|
||||
}
|
||||
|
||||
export async function initDatabase () {
|
||||
if (db) {
|
||||
return
|
||||
}
|
||||
|
||||
idx = lunr.Index.load(idxJson)
|
||||
|
||||
return new Promise<void>((resolve) => {
|
||||
db = new Loki(buildPath('data.loki'), {
|
||||
autoload: true,
|
||||
|
||||
Reference in new issue
Block a user