refactor: footer
This commit is contained in:
parent
e4402c5448
commit
af0049707a
@ -35,31 +35,34 @@ function postParser(el: Element | null): string {
|
|||||||
const body = el.querySelector('.js-post-body')?.innerHTML || '';
|
const body = el.querySelector('.js-post-body')?.innerHTML || '';
|
||||||
const voteCount = el.querySelector('.js-vote-count')?.textContent || '';
|
const voteCount = el.querySelector('.js-vote-count')?.textContent || '';
|
||||||
|
|
||||||
const footer = [...el.querySelectorAll('.post-signature')].map((el) => {
|
const footer = [...el.querySelectorAll('.post-signature')]
|
||||||
const userName = el.querySelector('.user-details a')?.textContent || '';
|
.map((el) => {
|
||||||
const userUrl =
|
const userName = el.querySelector('.user-details a')?.textContent || '';
|
||||||
(el.querySelector('.user-details a') as HTMLAnchorElement)?.href || '';
|
const userUrl =
|
||||||
const userTitle = el.querySelector('.user-action-time')?.textContent || '';
|
(el.querySelector('.user-details a') as HTMLAnchorElement)?.href || '';
|
||||||
|
const userTitle =
|
||||||
|
el.querySelector('.user-action-time')?.textContent || '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<h4>
|
<h4>
|
||||||
{userTitle}
|
{userTitle}
|
||||||
{userUrl ? (
|
{userUrl ? (
|
||||||
<>
|
<>
|
||||||
by <a href={userUrl}>{userName}</a>
|
by <a href={userUrl}>{userName}</a>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
</h4>
|
</h4>
|
||||||
);
|
);
|
||||||
});
|
})
|
||||||
|
.join('');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h3>{voteCount} votes</h3>
|
<h3>{voteCount} votes</h3>
|
||||||
{body}
|
{body}
|
||||||
{footer.join('')}
|
{footer}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user