@@ -51,6 +51,22 @@ export default defineComponent({
51
51
} ,
52
52
53
53
setup ( props ) {
54
+ const componentCount : { [ key : string ] : Record < string , number > } = { } ;
55
+
56
+ const resetCounter = ( ) => {
57
+ Object . keys ( componentCount ) . forEach ( ( key ) => {
58
+ componentCount [ key ] = { } ;
59
+ } )
60
+ }
61
+
62
+ const getNextKey = ( type : string , id : string ) => {
63
+ const counter = componentCount [ type ] ||= { } ;
64
+ const count = counter [ id ] || 0 ;
65
+ counter [ id ] = count + 1 ;
66
+ const key = `${ type } -${ id } -${ count } ` ;
67
+ return key ;
68
+ }
69
+
54
70
const walkNodes = ( node : HTMLElement ) : any => {
55
71
// h()でvNodeを作る時点で子ノードの一覧が必要になるため、以下の順で処理します。
56
72
// 1. visit: vNode作成の基本情報
@@ -152,10 +168,14 @@ export default defineComponent({
152
168
return newVNode ;
153
169
} ,
154
170
departIssue ( node : HTMLElement , vNode : VNode ) : VNode {
171
+ const id = node . dataset [ "issue" ] as string ;
172
+ const key = getNextKey ( "issue" , id ) ;
173
+
155
174
const newVNode : VNode = {
156
175
type : MarkdownRendererIssue ,
157
176
props : {
158
- id : node . dataset [ "issue" ] ,
177
+ key,
178
+ id,
159
179
} ,
160
180
children : null ,
161
181
} ;
@@ -172,6 +192,7 @@ export default defineComponent({
172
192
const outer = document . createElement ( "div" ) ;
173
193
outer . innerHTML = props . content ;
174
194
195
+ resetCounter ( )
175
196
return walkNodes ( outer ) ;
176
197
} ;
177
198
} ,
0 commit comments