feat(admin): auto-expand news item if there is only one
This commit is contained in:
parent
03c06ba0b8
commit
f1bde962cc
@ -17,6 +17,7 @@ export type ArticleProps = {
|
|||||||
url: string;
|
url: string;
|
||||||
content_html: string;
|
content_html: string;
|
||||||
date_published: string;
|
date_published: string;
|
||||||
|
defaultOpen?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ArticleItem: FC<ArticleProps> = ({
|
const ArticleItem: FC<ArticleProps> = ({
|
||||||
@ -24,12 +25,13 @@ const ArticleItem: FC<ArticleProps> = ({
|
|||||||
url,
|
url,
|
||||||
content_html: content,
|
content_html: content,
|
||||||
date_published: date,
|
date_published: date,
|
||||||
|
defaultOpen = false,
|
||||||
}) => {
|
}) => {
|
||||||
const dateObject = new Date(date);
|
const dateObject = new Date(date);
|
||||||
const dateString = format(dateObject, 'MMM dd, yyyy, HH:mm');
|
const dateString = format(dateObject, 'MMM dd, yyyy, HH:mm');
|
||||||
return (
|
return (
|
||||||
<article>
|
<article>
|
||||||
<Collapse>
|
<Collapse defaultActiveKey={defaultOpen ? url : null}>
|
||||||
<Panel header={title} key={url}>
|
<Panel header={title} key={url}>
|
||||||
<p className="timestamp">
|
<p className="timestamp">
|
||||||
{dateString} (
|
{dateString} (
|
||||||
@ -74,7 +76,7 @@ export const NewsFeed = () => {
|
|||||||
<Title level={2}>News & Updates from Owncast</Title>
|
<Title level={2}>News & Updates from Owncast</Title>
|
||||||
{loadingSpinner}
|
{loadingSpinner}
|
||||||
{feed.map(item => (
|
{feed.map(item => (
|
||||||
<ArticleItem {...item} key={item.url} />
|
<ArticleItem {...item} key={item.url} defaultOpen={feed.length === 1} />
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{noNews}
|
{noNews}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user