mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-05 03:02:56 +00:00
de day #74
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import React from 'react';
|
||||
import { assetUrl } from '../../utils/url';
|
||||
|
||||
export type NewsListItem = {
|
||||
id: number | string;
|
||||
title: string;
|
||||
excerpt?: string;
|
||||
image?: string;
|
||||
slug?: string;
|
||||
};
|
||||
|
||||
const NewsList: React.FC<{
|
||||
items: NewsListItem[];
|
||||
emptyText?: string;
|
||||
seeAllHref?: string;
|
||||
seeAllLabel?: string;
|
||||
}> = ({ items, emptyText = 'Zatím nejsou k dispozici žádné aktuality.', seeAllHref, seeAllLabel = 'Zobrazit všechny aktuality' }) => {
|
||||
return (
|
||||
<>
|
||||
<div className="blog-list">
|
||||
{items && items.length > 0 ? (
|
||||
items.slice(0, 4).map((n) => (
|
||||
<a key={n.id} href={`/news/${n.slug || n.id}`} className="card" style={{ textDecoration: 'none', color: 'inherit' }}>
|
||||
<div className="thumb" style={{ backgroundImage: `url(${assetUrl(n.image) || '/images/news/placeholder.jpg'})` }} />
|
||||
<div>
|
||||
<h4>{n.title}</h4>
|
||||
{n.excerpt && (
|
||||
<div style={{ color: 'var(--dark-gray)', fontSize: '0.9rem' }}>{n.excerpt}</div>
|
||||
)}
|
||||
</div>
|
||||
</a>
|
||||
))
|
||||
) : (
|
||||
<div style={{ padding: '24px', textAlign: 'center', color: 'var(--dark-gray)', background: 'var(--bg-soft)', borderRadius: '12px' }}>
|
||||
<p>{emptyText}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{seeAllHref && items && items.length > 0 && (
|
||||
<div style={{ marginTop: 12 }}>
|
||||
<a className="btn" href={seeAllHref}>{seeAllLabel}</a>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default NewsList;
|
||||
Reference in New Issue
Block a user