@@ -11,12 +11,9 @@ import {
1111 STABILITY_LEVELS ,
1212 CHANGE_TYPES ,
1313} from '../constants.mjs' ;
14- import {
15- DOC_API_BLOB_EDIT_BASE_URL ,
16- DOC_NODE_BLOB_BASE_URL ,
17- } from '../../../constants.mjs' ;
14+ import { DOC_NODE_BLOB_BASE_URL } from '../../../constants.mjs' ;
1815import { enforceArray , sortChanges } from '../../../utils/generators.mjs' ;
19- import readingTime from 'reading-time ' ;
16+ import { buildMetaBarProps } from './buildBarProps.mjs ' ;
2017
2118/**
2219 * Transforms a stability node into an AlertBox JSX element
@@ -151,50 +148,6 @@ function processEntry(entry) {
151148 return content ;
152149}
153150
154- /**
155- * Collects text content from nodes for reading time calculation
156- *
157- * @param {Array<ApiDocMetadataEntry> } entries - The API metadata entries
158- * @returns {string } Concatenated text content
159- */
160- function collectTextContent ( entries ) {
161- let text = '' ;
162- entries . forEach ( entry => {
163- visit ( entry . content , [ 'text' , 'code' ] , node => {
164- text += node . value || '' ;
165- } ) ;
166- } ) ;
167- return text ;
168- }
169-
170- /**
171- * Builds the metadata for the sidebar and meta bar
172- *
173- * @param {ApiDocMetadataEntry } head - The main API metadata entry
174- * @param {Array<ApiDocMetadataEntry> } entries - The API metadata entries
175- * @returns {Object } Props for meta bar including headings and reading time
176- */
177- function buildMetaBarProps ( head , entries ) {
178- // Extract headings in one pass
179- const headings = entries
180- . filter ( ( { heading } ) => heading ?. data ?. name )
181- . map ( ( { heading } ) => ( {
182- depth : heading . depth ,
183- value : heading . data . name ,
184- } ) ) ;
185-
186- // Calculate reading time
187- const text = collectTextContent ( entries ) ;
188-
189- return {
190- headings,
191- addedIn : head . introduced_in || head . added_in || '' ,
192- readingTime : readingTime ( text ) . text ,
193- viewAs : [ [ 'JSON' , `${ head . api } .json` ] ] ,
194- editThisPage : `${ DOC_API_BLOB_EDIT_BASE_URL } ${ head . api } .md` ,
195- } ;
196- }
197-
198151/**
199152 * Creates the overall content structure with processed entries
200153 *
0 commit comments