File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -41,17 +41,19 @@ export default defineNuxtModule<ModuleOptions>({
41
41
// @nuxt /content support
42
42
( component , code ) => {
43
43
code = code . replace (
44
- / < C o n t e n t S l o t ( . * ) ? : u s e = " \$ s l o t s \. ( [ a - z ] + ) " ( . * ) \/ > / gm,
44
+ / < C o n t e n t S l o t \s * ( [ ^ > ] * ) ? : u s e = " \$ s l o t s \. ( [ a - z A - Z 0 - 9 _ ] + ) " / gm,
45
45
( _ , _before , slotName , _rest ) => {
46
- return `<slot ${ slotName === 'default' ? '' : `name="${ slotName } "` } /> `
46
+ return `<slot ${ _before || '' } ${ slotName === 'default' ? '' : `name="${ slotName } "` } `
47
47
}
48
48
)
49
49
code = code . replace (
50
- / < C o n t e n t S l o t ( . * ) ? n a m e = " ( [ a - z ] + ) " ( . * ) \/ > / gm,
50
+ / < C o n t e n t S l o t \s * ( [ ^ > ] * ) ? n a m e = " ( [ a - z A - Z 0 - 9 _ ] + ) " / gm,
51
51
( _ , _before , slotName , _rest ) => {
52
- return `<slot ${ slotName === 'default' ? '' : `name="${ slotName } "` } /> `
52
+ return `<slot ${ _before || '' } ${ slotName === 'default' ? '' : `name="${ slotName } "` } `
53
53
}
54
54
)
55
+ code = code . replace ( / < \/ C o n t e n t S l o t > / gm, '</slot>' )
56
+
55
57
// Handle `(const|let|var) slots = useSlots()`
56
58
const name = code . match ( / ( c o n s t | l e t | v a r ) ( [ a - z A - Z ] [ a - z A - Z - _ 0 - 9 ] * ) = u s e S l o t s \( \) / ) ?. [ 2 ] || '$slots'
57
59
const _slots = code . match ( new RegExp ( `${ name } \\.[a-zA-Z]+` , 'gm' ) )
You can’t perform that action at this time.
0 commit comments