11import { h as createElement } from 'hastscript' ;
2- import { slice , findText } from 'mdast-util-slice-markdown' ;
2+ import { slice } from 'mdast-util-slice-markdown' ;
33import { u as createTree } from 'unist-builder' ;
44import { SKIP , visit } from 'unist-util-visit' ;
55
@@ -17,6 +17,7 @@ import {
1717 INTERNATIONALIZABLE ,
1818 STABILITY_PREFIX_LENGTH ,
1919 TYPES_WITH_METHOD_SIGNATURES ,
20+ TYPE_PREFIX_LENGTH ,
2021} from '../constants.mjs' ;
2122import insertSignature , { getFullName } from './buildSignature.mjs' ;
2223
@@ -105,15 +106,7 @@ export const extractHeadingContent = content => {
105106 return type === 'ctor' ? `${ fullName } Constructor` : fullName ;
106107 }
107108
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 ;
117110} ;
118111
119112/**
@@ -185,6 +178,22 @@ export const transformHeadingNode = (entry, remark, node, index, parent) => {
185178 createChangeElement ( entry , remark )
186179 ) ;
187180
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+
188197 // Add source link element if available, right after heading
189198 const sourceLink = createSourceLink ( entry . source_link ) ;
190199
0 commit comments