Skip to content

Commit 8ea4de1

Browse files
committed
fix: prevent import cache in development
1 parent e098115 commit 8ea4de1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import { eventHandler, getRouterParam } from 'h3'
2+
import { useStorage } from 'nitropack/runtime'
23

34
export default eventHandler(async (event) => {
45
const collection = getRouterParam(event, 'collection')!
56

7+
const data = await useStorage().getItem(`build:content:database.compressed.mjs`) || ''
8+
if (data) {
9+
const lineStart = `export const ${collection} = "`
10+
const content = String(data).split('\n').find(line => line.startsWith(lineStart))
11+
if (content) {
12+
return content
13+
.substring(lineStart.length, content.length - 1)
14+
}
15+
}
16+
617
return await import('#content/dump').then(m => m[collection])
718
})

0 commit comments

Comments
 (0)