@@ -162,14 +162,21 @@ function resolveContentComponents(body: MDCRoot, meta: Record<string, unknown>)
162162 return
163163 }
164164 const components = Array .from (new Set (loadComponents (body , meta as { tags: Record <string , string > })))
165- const res = components .map ((c ) => {
166- if (typeof c === ' object' && renderFunctions .some (fn => Object .hasOwnProperty .call (c , fn ))) {
167- return [false , false ]
165+
166+ const result = {} as Record <string , unknown >
167+ for (const [tag, component] of components ) {
168+ if (typeof component === ' object' && renderFunctions .some (fn => Object .hasOwnProperty .call (component , fn ))) {
169+ continue
170+ }
171+
172+ if (result [tag ]) {
173+ continue
168174 }
169- const resolvedComponent = resolveVueComponent (c as string )
170- return [c , resolvedComponent ]
171- })
172- return Object .fromEntries (res .filter (item => Boolean (item [0 ])))
175+
176+ result [tag ] = resolveVueComponent (component as string )
177+ }
178+
179+ return result as Exclude <(InstanceType <typeof MDCRenderer >)[' $props' ][' components' ], undefined >
173180}
174181
175182function loadComponents(node : MDCRoot | MDCElement , documentMeta : { tags: Record <string , string > }) {
@@ -178,9 +185,9 @@ function loadComponents(node: MDCRoot | MDCElement, documentMeta: { tags: Record
178185 return []
179186 }
180187 const renderTag = findMappedTag (node as unknown as MDCElement , documentMeta .tags )
181- const components2 = [] as unknown []
188+ const components2 = [] as Array <[ string , unknown ]>
182189 if ((node as unknown as MDCRoot ).type !== ' root' && ! htmlTags .includes (renderTag )) {
183- components2 .push (renderTag )
190+ components2 .push ([ tag , renderTag ] )
184191 }
185192 for (const child of node .children || []) {
186193 components2 .push (... loadComponents (child as MDCElement , documentMeta ))
0 commit comments