Skip to content

Commit 3b5a80e

Browse files
authored
fix(ContentList): handle props change and fix slots default (#1668)
1 parent 37e2caf commit 3b5a80e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/runtime/components/ContentList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ export default defineComponent({
6060
? ({ data, refresh, isPartial }) => slots?.default({ list: data, refresh, isPartial, ...this.$attrs })
6161
: ({ data }) => emptyNode('default', data),
6262
// Empty slot
63-
empty: bindings => slots?.empty ? slots.empty(bindings) : ({ data }) => emptyNode('default', data),
63+
empty: bindings => slots?.empty ? slots.empty(bindings) : emptyNode('default', bindings?.data),
6464
// Not Found slot
65-
'not-found': bindings => slots?.['not-found'] ? slots?.['not-found']?.(bindings) : ({ data }) => emptyNode('not-found', data)
65+
'not-found': bindings => slots?.['not-found'] ? slots?.['not-found']?.(bindings) : emptyNode('not-found', bindings?.data)
6666
}
6767
)
6868
}

src/runtime/components/ContentQuery.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { hash } from 'ohash'
3-
import { PropType, toRefs, defineComponent, h, useSlots } from 'vue'
3+
import { PropType, toRefs, defineComponent, h, useSlots, watch } from 'vue'
44
import type { ParsedContent, QueryBuilder, SortParams } from '../types'
55
import { computed, useAsyncData, queryContent } from '#imports'
66
@@ -143,6 +143,8 @@ export default defineComponent({
143143
}
144144
)
145145
146+
watch(() => props, () => refresh(), { deep: true })
147+
146148
return {
147149
isPartial,
148150
data,
@@ -194,7 +196,7 @@ export default defineComponent({
194196
if (!data && slots?.['not-found']) { return slots['not-found']({ props, ...this.$attrs }) }
195197
196198
// Empty slots for `one` if type is "markdown" refers to an empty `body.children` key.
197-
if (data?._type === 'markdown' && !data?.body?.children.length) { return slots.empty({ props, ...this.$attrs }) }
199+
if (slots?.empty && data?._type === 'markdown' && !data?.body?.children.length) { return slots.empty({ props, ...this.$attrs }) }
198200
} else if (!data || !data.length) {
199201
// Handle `find()` and `findSurround()`
200202

0 commit comments

Comments
 (0)