Skip to content

Commit

Permalink
fix(findSurround): use filtered contents to find surround (#2291)
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Sep 6, 2023
1 parent faff26b commit 6d70135
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/runtime/query/match/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function createPipelineFetcher<T> (getContentsList: () => Promise<T[]>) {
function fetchSurround (state, params, db) {
if (params.surround) {
// @ts-ignore
state.surround = surround(db, params.surround)
state.surround = surround(state.result?.length === 1 ? db : state.result, params.surround)
}
return state
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/query/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function createQuery <T = ParsedContent> (fetcher: ContentQueryFetcher<T>
if (opts.legacy) {
// @ts-ignore
query.findSurround = (surroundQuery, options) => {
return query.withSurround(surroundQuery, options).findOne().then(resolveResult)
return query.withSurround(surroundQuery, options).find().then(resolveResult)
}

return query as QueryBuilder<T>
Expand Down

0 comments on commit 6d70135

Please sign in to comment.