Merge related links

This commit is contained in:
Sam Carlton 2021-05-25 09:34:04 -05:00
parent 33c7623bfd
commit 86ed9f50c8

View file

@ -284,6 +284,7 @@ export default async function () {
let bundleId = null
let tags = []
let aliases = []
const relatedLinksMap = new Map( getTokenLinks(token.children).map( link => [ link.href, link ] ) )
// Search for this app in the scanList and remove duplicates
scanListMap.forEach( ( scannedApp, key ) => {
@ -308,13 +309,26 @@ export default async function () {
...scannedApp.aliases
]))
// Merge relatated links
for ( const link of scannedApp.relatedLinks ) {
relatedLinksMap.set( link.href, {
...link,
label: (link.label === 'View') ? 'App Website' : link.label
} )
}
console.log(`Merged ${alias} (${scannedApp.bundleId}) from scanned apps into ${name} from README`)
scanListMap.delete( key )
}
}
})
const relatedLinks = getTokenLinks(token.children)
// Convert link map values into array for JSON
const relatedLinks = Array.from( relatedLinksMap.values() )
// console.log('relatedLinks', relatedLinks)
const appSlug = makeSlug( name )