make miniToc pure data and no html strings (#28517)
* make miniToc pure data and no html strings * fixups * some types refactoring
This commit is contained in:
@@ -43,9 +43,7 @@ export default function getMiniTocItems(
|
||||
// remove any <strong> tags but leave content
|
||||
$('strong', item).map((i, el) => $(el).replaceWith($(el).contents()))
|
||||
|
||||
const contents = isRestPage
|
||||
? { href: `${href}`, title: `${$(item).text()}` }
|
||||
: `<a class="d-block width-auto" href="${href}">${$(item).html()}</a>`
|
||||
const contents = { href, title: $(item).text().trim() }
|
||||
const headingLevel = parseInt($(item)[0].name.match(/\d+/)[0], 10) || 0 // the `2` from `h2`
|
||||
|
||||
const platform = $(item).parent('.extended-markdown').attr('class') || ''
|
||||
|
||||
@@ -103,7 +103,7 @@ export async function getRestMiniTocItems(
|
||||
// is needed to generate the toc
|
||||
const titles = restOperations.map((operation) => `### ${operation.title}\n`).join('')
|
||||
toc += await renderContent(titles, context)
|
||||
const restOperationsMiniTocItems = getMiniTocItems(toc, 3, '', true)
|
||||
const restOperationsMiniTocItems = getMiniTocItems(toc, 3, '')
|
||||
languageTree.get(version).get(category).set(subCategory, {
|
||||
restOperationsMiniTocItems,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user