1
1
import { h as createElement } from 'hastscript' ;
2
- import { slice , findText } from 'mdast-util-slice-markdown' ;
2
+ import { slice } from 'mdast-util-slice-markdown' ;
3
3
import { u as createTree } from 'unist-builder' ;
4
4
import { SKIP , visit } from 'unist-util-visit' ;
5
5
@@ -17,6 +17,7 @@ import {
17
17
INTERNATIONALIZABLE ,
18
18
STABILITY_PREFIX_LENGTH ,
19
19
TYPES_WITH_METHOD_SIGNATURES ,
20
+ TYPE_PREFIX_LENGTH ,
20
21
} from '../constants.mjs' ;
21
22
import insertSignature , { getFullName } from './buildSignature.mjs' ;
22
23
@@ -105,15 +106,7 @@ export const extractHeadingContent = content => {
105
106
return type === 'ctor' ? `${ fullName } Constructor` : fullName ;
106
107
}
107
108
108
- // Find the index of the first colon, i.e. `Class:`.
109
- const colonPos = findText ( content , ':' ) [ 0 ] ;
110
-
111
- if ( ! colonPos ) {
112
- return content . children ;
113
- }
114
-
115
- // Slice out the prefix from the index gotten above.
116
- return slice ( content , colonPos + 1 ) . node . children ;
109
+ return content . children ;
117
110
} ;
118
111
119
112
/**
@@ -185,6 +178,22 @@ export const transformHeadingNode = (entry, remark, node, index, parent) => {
185
178
createChangeElement ( entry , remark )
186
179
) ;
187
180
181
+ if ( entry . api === 'deprecations' && node . depth === 3 ) {
182
+ // On the 'deprecations.md' page, "Type: <XYZ>" turns into an AlertBox
183
+ parent . children [ index + 1 ] = createJSXElement ( JSX_IMPORTS . AlertBox . name , {
184
+ children : slice (
185
+ parent . children [ index + 1 ] ,
186
+ TYPE_PREFIX_LENGTH ,
187
+ undefined ,
188
+ {
189
+ textHandling : { boundaries : 'preserve' } ,
190
+ }
191
+ ) . node . children ,
192
+ level : 'danger' ,
193
+ title : 'Type' ,
194
+ } ) ;
195
+ }
196
+
188
197
// Add source link element if available, right after heading
189
198
const sourceLink = createSourceLink ( entry . source_link ) ;
190
199
0 commit comments