diff --git a/src/runtime/components/ContentList.vue b/src/runtime/components/ContentList.vue index 7f6cd6f5f..404f527d9 100644 --- a/src/runtime/components/ContentList.vue +++ b/src/runtime/components/ContentList.vue @@ -17,7 +17,7 @@ export default defineComponent({ path: { type: String, required: false, - default: '/' + default: undefined }, /** @@ -44,7 +44,10 @@ export default defineComponent({ const { path, query } = ctx // Merge local `path` props and apply `findOne` query default. - const contentQueryProps = Object.assign(query || {}, { path }) + const contentQueryProps = { + ...query || {}, + path: path || query?.path || '/' + } const emptyNode = (slot: string, data: any) => h('pre', null, JSON.stringify({ message: 'You should use slots with ', slot, data }, null, 2)) diff --git a/test/features/components.ts b/test/features/components.ts index 82370bda9..68d450a6f 100644 --- a/test/features/components.ts +++ b/test/features/components.ts @@ -9,4 +9,11 @@ export const testComponents = () => { expect(index).toContain('Lorem ipsum dolor sit, amet consectetur adipisicing elit.') }) }) + + describe('', () => { + test('custom query', async () => { + const index = await $fetch('/dogs-list') + expect(index).toContain('[Bulldog,German Shepherd]') + }) + }) } diff --git a/test/fixtures/basic/pages/dogs-list.vue b/test/fixtures/basic/pages/dogs-list.vue new file mode 100644 index 000000000..ab77f48ff --- /dev/null +++ b/test/fixtures/basic/pages/dogs-list.vue @@ -0,0 +1,20 @@ + + +