Get hovercard info from pageinfo API (#36542)
This commit is contained in:
@@ -53,7 +53,6 @@ export default function rewriteLocalLinks(context) {
|
||||
const newHref = getNewHref(node, currentLanguage, currentVersion)
|
||||
if (newHref) {
|
||||
node.properties.href = newHref
|
||||
promises.push(dataAttributesSetter(node, context))
|
||||
}
|
||||
for (const child of node.children) {
|
||||
if (child.value) {
|
||||
@@ -98,43 +97,6 @@ export default function rewriteLocalLinks(context) {
|
||||
}
|
||||
}
|
||||
|
||||
async function dataAttributesSetter(node, context) {
|
||||
const href = node.properties.href
|
||||
const page = findPage(href, context.pages, context.redirects)
|
||||
if (!page) {
|
||||
// If this happens, it's a link that might be broken or links to
|
||||
// something that might not actually be an internal link to a
|
||||
// existing page such as link to archived enterprise version.
|
||||
return
|
||||
}
|
||||
let productPage = null
|
||||
for (const permalink of page.permalinks) {
|
||||
const rootHref = permalink.href
|
||||
.split('/')
|
||||
.slice(0, permalink.pageVersion === 'free-pro-team@latest' ? 3 : 4)
|
||||
.join('/')
|
||||
const rootPage = context.pages[rootHref]
|
||||
if (rootPage) {
|
||||
productPage = rootPage
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (productPage) {
|
||||
let productTitle = await productPage.renderProp('shortTitle', context, {
|
||||
textOnly: true,
|
||||
})
|
||||
if (!productTitle) {
|
||||
productTitle = await productPage.renderProp('title', context, {
|
||||
textOnly: true,
|
||||
})
|
||||
}
|
||||
node.properties['data-product-title'] = productTitle
|
||||
}
|
||||
node.properties['data-title'] = await page.renderProp('title', context, { textOnly: true })
|
||||
node.properties['data-intro'] = await page.renderProp('intro', context, { textOnly: true })
|
||||
}
|
||||
|
||||
async function getNewTitleSetter(child, href, context) {
|
||||
child.value = await getNewTitle(href, context)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user