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) {
|
if (s && s.text) {
|
||||||
let div = document.createElement('div');
|
let div = document.createElement('div');
|
||||||
div.innerHTML = s.text;
|
div.innerHTML = s.text;
|
||||||
let nodes = div.childNodes;
|
return div.childNodes;
|
||||||
while (nodes.length === 1 && nodes[0].localName) {
|
|
||||||
nodes = nodes[0].childNodes;
|
|
||||||
}
|
|
||||||
return nodes;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const storyNodes = nodes(story);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='article-container'>
|
<div className='article-container'>
|
||||||
{error &&
|
{error &&
|
||||||
@@ -155,9 +153,9 @@ function Article({ cache }) {
|
|||||||
|
|
||||||
{infoLine(story)}
|
{infoLine(story)}
|
||||||
|
|
||||||
{nodes(story) ?
|
{storyNodes ?
|
||||||
<div className='story-text'>
|
<div className='story-text'>
|
||||||
{renderNodes(nodes(story))}
|
{renderNodes(storyNodes)}
|
||||||
</div>
|
</div>
|
||||||
:
|
:
|
||||||
<p>Problem getting article :(</p>
|
<p>Problem getting article :(</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user