import { h } from 'preact'; import PropTypes from 'prop-types'; /* global timeAgo */ function userProfilePage(username) { const str = `/${username}`; return str; } function contentAwareComments(comment) { const parser = new DOMParser(); const htmlDoc = parser.parseFromString( comment.safe_processed_html, 'text/html', ); const nodes = htmlDoc.body.childNodes; let text = ''; let nodesSelected = 0; nodes.forEach((node) => { if ( node.outerHTML && (node.tagName === 'P' || node.className.includes('highlight')) && nodesSelected < 2 && node.outerHTML.length > 250 && !node.outerHTML.includes('article-body-image-wrapper') ) { node.innerHTML = `${node.innerHTML.substring(0, 230)}...`; text = `${text} ${node.outerHTML}`; nodesSelected = 2; } else if (node.outerHTML && nodesSelected < 2) { text = text + node.outerHTML; nodesSelected++; } else if (node.outerHTML && nodesSelected < 3) { text = `${text}