Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
unistVisit(tree, 'element', node => {
let cls = node.properties.className || []
if (node.tagName === 'article') {
node.children = []
} else if (node.tagName === 'a') {
if (cls.some(i => i === 'menu_link')) {
node.properties.className = cls.filter(i => i !== 'is-current')
}
} else if (cls[0] === 'submenu') {
node.children = []
} else if (cls[0] === 'menu_extra') {
node.children = [{ type: 'text', value: `(${ chatUsers } people)` }]
}
})
let articles = 0
return unistFilter(tree, 'element', node => {
let props = node.properties || { }
if (node.tagName === 'article') {
articles += 1
return articles === 1
} if (node.tagName === 'script') {
return !removeAssets.some(i => props.src.includes(i))
} else if (node.tagName === 'link' && props.rel[0] === 'stylesheet') {
return !removeAssets.some(i => props.href.includes(i))
} else if (node.tagName === 'link' && props.rel[0] === 'preload') {
return !removeAssets.some(i => props.href.includes(i))
} else if (node.tagName === 'link' && props.rel[0] === 'preconnect') {
return !removeAssets.some(i => props.href.includes(i))
} else {
return true
}
})