Skip to content

Commit

Permalink
fix: better default fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Dec 14, 2022
1 parent 5f9d5b5 commit 0a7b13a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/runtime/composables/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export const fetchContentNavigation = async (queryBuilder?: QueryBuilder | Query
// - query doesn't already have a locale filter
if (content.locales.length) {
const queryLocale = params.where?.find(w => w._locale)?._locale
const locale = queryLocale || content.defaultLocale
params.where = params.where || []
params.where.push({ _locale: locale })
if (!queryLocale) {
params.where = params.where || []
params.where.push({ _locale: content.defaultLocale })
}
}

const _apiPath = params ? `/navigation/${hash(params)}` : '/navigation/'
Expand Down
5 changes: 3 additions & 2 deletions src/runtime/composables/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export const createQueryFetch = <T = ParsedContent>(path?: string) => async (que
// - query doesn't already have a locale filter
if (content.locales.length) {
const queryLocale = query.params().where?.find(w => w._locale)?._locale
const locale = queryLocale || content.defaultLocale
query.locale(locale)
if (!queryLocale) {
query.locale(content.defaultLocale)
}
}

const params = query.params()
Expand Down
5 changes: 3 additions & 2 deletions src/runtime/server/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ export const createServerQueryFetch = <T = ParsedContent>(event: H3Event, path?:
// - query doesn't already have a locale filter
if (contentConfig.locales.length) {
const queryLocale = query.params().where?.find(w => w._locale)?._locale
const locale = queryLocale || contentConfig.defaultLocale
query.locale(locale)
if (!queryLocale) {
query.locale(contentConfig.defaultLocale)
}
}

return createPipelineFetcher<T>(() => getIndexedContentsList<T>(event, query))(query)
Expand Down

0 comments on commit 0a7b13a

Please sign in to comment.