Skip to content

Commit 1afb37c

Browse files
authored
Revert "feat: create index for path base search (#1401)"
This reverts commit 2602c07.
1 parent 2602c07 commit 1afb37c

File tree

7 files changed

+8
-66
lines changed

7 files changed

+8
-66
lines changed

src/module.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,16 +533,12 @@ export default defineNuxtModule<ModuleOptions>({
533533
nitro.options.runtimeConfig.public.content.wsUrl = url.replace('http', 'ws')
534534

535535
// Watch contents
536-
await nitro.storage.watch(async (event: WatchEvent, key: string) => {
536+
await nitro.storage.watch((event: WatchEvent, key: string) => {
537537
// Ignore events that are not related to content
538538
if (!key.startsWith(MOUNT_PREFIX)) {
539539
return
540540
}
541541
key = key.substring(MOUNT_PREFIX.length)
542-
543-
// Remove content Index
544-
await nitro.storage.removeItem('cache:content:content-index.json')
545-
546542
// Broadcast a message to the server to refresh the page
547543
ws.broadcast({ event, key })
548544
})

src/runtime/composables/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const createQueryFetch = <T = ParsedContent>(path?: string) => (query: Qu
3535
})
3636
}
3737

38-
return $fetch(apiPath as any, {
38+
return $fetch<T | T[]>(apiPath as any, {
3939
method: 'GET',
4040
responseType: 'json',
4141
params: {

src/runtime/server/api/cache.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
import { defineEventHandler } from 'h3'
2-
import { getContentIndex } from '../content-index'
3-
import { cacheStorage, serverQueryContent } from '../storage'
2+
import { serverQueryContent } from '../storage'
43

54
// This route is used to cache all the parsed content
65
export default defineEventHandler(async (event) => {
76
const now = Date.now()
87
// Fetch all content
98
await serverQueryContent(event).find()
109

11-
// Generate Index
12-
await getContentIndex(event)
13-
14-
const navigation = await $fetch('/api/_content/navigation')
15-
await cacheStorage.setItem('content-navigation.json', navigation)
16-
1710
return {
1811
generatedAt: now,
1912
generateTime: Date.now() - now

src/runtime/server/api/navigation.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
import { defineEventHandler } from 'h3'
2-
import { cacheStorage, serverQueryContent } from '../storage'
2+
import { serverQueryContent } from '../storage'
33
import { createNav } from '../navigation'
44
import { ParsedContentMeta } from '../../types'
55
import { getContentQuery } from '../../utils/query'
6-
import { isPreview } from '../preview'
76

87
export default defineEventHandler(async (event) => {
98
const query = getContentQuery(event)
109

11-
// Read from cache if not preview and there is no query
12-
if (!isPreview(event) && Object.keys(query).length === 0) {
13-
const cache = cacheStorage.getItem('content-navigation.json')
14-
if (cache) {
15-
return cache
16-
}
17-
}
18-
1910
const contents = await serverQueryContent(event, query)
2011
.where({
2112
/**

src/runtime/server/content-index.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/runtime/server/storage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { createPipelineFetcher } from '../query/match/pipeline'
1010
import { transformContent } from '../transformers'
1111
import type { ModuleOptions } from '../../module'
1212
import { getPreview, isPreview } from './preview'
13-
import { getIndexedContentsList } from './content-index'
1413
// eslint-disable-next-line import/named
1514
// @ts-ignore
1615
import { useNitroApp, useRuntimeConfig, useStorage } from '#imports'
@@ -201,7 +200,9 @@ export const createServerQueryFetch = <T = ParsedContent>(event: CompatibilityEv
201200
query.sort({ _file: 1, $numeric: true })
202201
}
203202

204-
return createPipelineFetcher<T>(() => getIndexedContentsList<T>(event, query))(query)
203+
return createPipelineFetcher<T>(
204+
() => getContentsList(event) as unknown as Promise<T[]>
205+
)(query)
205206
}
206207

207208
/**

src/runtime/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ export interface QueryBuilder<T = ParsedContentMeta> {
471471
/**
472472
* Fetch sorround contents
473473
*/
474-
findSurround(query: string | QueryBuilderWhere, options?: Partial<{ before: number; after: number }>): Promise<Array<T>>
474+
findSurround(query: string | object, options?: Partial<{ before: number; after: number }>): Promise<Array<T>>
475475

476476
/**
477477
* Filter contents based on locale

0 commit comments

Comments
 (0)