forked from tanner/qotnews
refactor: Optimize nodes() calls and simplify function in Article
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -122,15 +122,13 @@ function Article({ cache }) {
|
||||
if (s && s.text) {
|
||||
let div = document.createElement('div');
|
||||
div.innerHTML = s.text;
|
||||
let nodes = div.childNodes;
|
||||
while (nodes.length === 1 && nodes[0].localName) {
|
||||
nodes = nodes[0].childNodes;
|
||||
}
|
||||
return nodes;
|
||||
return div.childNodes;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const storyNodes = nodes(story);
|
||||
|
||||
return (
|
||||
<div className='article-container'>
|
||||
{error &&
|
||||
@@ -155,9 +153,9 @@ function Article({ cache }) {
|
||||
|
||||
{infoLine(story)}
|
||||
|
||||
{nodes(story) ?
|
||||
{storyNodes ?
|
||||
<div className='story-text'>
|
||||
{renderNodes(nodes(story))}
|
||||
{renderNodes(storyNodes)}
|
||||
</div>
|
||||
:
|
||||
<p>Problem getting article :(</p>
|
||||
|
||||
Reference in New Issue
Block a user