diff --git a/src/runtime/server/api/navigation.ts b/src/runtime/server/api/navigation.ts index 7bc4bb7a7..dcfd381f2 100644 --- a/src/runtime/server/api/navigation.ts +++ b/src/runtime/server/api/navigation.ts @@ -10,7 +10,7 @@ export default defineEventHandler(async (event) => { // Read from cache if not preview and there is no query if (!isPreview(event) && Object.keys(query).length === 0) { - const cache = cacheStorage.getItem('content-navigation.json') + const cache = await cacheStorage.getItem('content-navigation.json') if (cache) { return cache } diff --git a/src/runtime/utils/query.ts b/src/runtime/utils/query.ts index 7d0b5fd39..c5bb6bba6 100644 --- a/src/runtime/utils/query.ts +++ b/src/runtime/utils/query.ts @@ -40,15 +40,21 @@ export const getContentQuery = (event: CompatibilityEvent): QueryBuilderParams = query.without = query.without.split(',').map(s => s.trim()) } - query.where = query.where || {} + const where = query.where || {} // ?partial=true|false&draft=true|false&empty=true|false for (const key of ['draft', 'partial', 'empty']) { // ?partial=true|false if (query[key] && ['true', 'false'].includes(query[key])) { - query.where[key] = query[key] === 'true' + where[key] = query[key] === 'true' delete query[key] } } + if (Object.keys(where).length > 0) { + query.where = [where] + } else { + delete query.where + } + // ?sortyBy=size:1 if (query.sort) { query.sort = query.sort.split(',').map((s) => {