Skip to content

Commit 813f98f

Browse files
fix: remobe Kirby prefetch type prefix
1 parent 672c205 commit 813f98f

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

docs/guide/prefetching-queries.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Finally, the query result will be importable from `#build/kql`:
3737
import { site } from '#build/kql'
3838

3939
// Import the type for the query result above
40-
import type { KirbySite } from '#build/kql'
40+
import type { Site } from '#build/kql'
4141
```
4242

4343
::: info
44-
The actual **type** for the key will be pascal cased and prefixed by `Kirby`, e. g. the key `somePageKey` will result in the type name `KirbySomePageKey`.
44+
The actual **type** for the key will be pascal cased, e. g. the key `somePageKey` will result in the type `SomePageKey`.
4545
:::

src/module.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,16 @@ ${(await readFile(resolve('runtime/types.d.ts'), 'utf-8'))
207207
filename: 'kql.ts',
208208
write: true,
209209
getContents() {
210-
return Object.entries(prefetchResults).map(([key, response]) => [
211-
`export const ${key} = ${response?.result ? JSON.stringify(response.result) : '{} as Record<string, any>'}`,
212-
`export type Kirby${pascalCase(key)} = typeof ${key}`,
213-
].join('\n')).join('\n')
210+
return Object.entries(prefetchResults)
211+
.map(
212+
([key, response]) =>
213+
`export const ${key} = ${
214+
response?.result
215+
? JSON.stringify(response.result, undefined, 2)
216+
: '{} as Record<string, any>'
217+
}\n` + `export type ${pascalCase(key)} = typeof ${key}\n`,
218+
)
219+
.join('\n')
214220
},
215221
})
216222

0 commit comments

Comments
 (0)