Add date meta to json and new tag to ui
This commit is contained in:
+13
-1
@@ -1,7 +1,18 @@
|
|||||||
import "./Card.css";
|
import "./Card.css";
|
||||||
|
|
||||||
export default function Card(props) {
|
export default function Card(props) {
|
||||||
const { href, title, body, tag } = props;
|
const { href, title, body, tag, dateAdded } = props;
|
||||||
|
|
||||||
|
const isNew = () => {
|
||||||
|
if (!dateAdded) return false;
|
||||||
|
|
||||||
|
const addedDate = new Date(dateAdded);
|
||||||
|
const today = new Date();
|
||||||
|
const differenceInTime = today.getTime() - addedDate.getTime();
|
||||||
|
const differenceInDays = differenceInTime / (1000 * 3600 * 24);
|
||||||
|
|
||||||
|
return differenceInDays <= 30;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className="link-card">
|
<li className="link-card">
|
||||||
@@ -9,6 +20,7 @@ export default function Card(props) {
|
|||||||
<strong className="nu-c-h6 nu-u-mt-1 nu-u-mb-1">{title}</strong>
|
<strong className="nu-c-h6 nu-u-mt-1 nu-u-mb-1">{title}</strong>
|
||||||
<p className="nu-c-fs-small nu-u-mt-1 nu-u-mb-1">{body}</p>
|
<p className="nu-c-fs-small nu-u-mt-1 nu-u-mb-1">{body}</p>
|
||||||
<p className="distribution">
|
<p className="distribution">
|
||||||
|
{isNew() && <span className="tag nu-u-me-2">New</span>}
|
||||||
<span className="tag">{tag}</span>
|
<span className="tag">{tag}</span>
|
||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ export default function CardsContainer({ filter }) {
|
|||||||
return (
|
return (
|
||||||
<section>
|
<section>
|
||||||
<ul role="list" className="link-card-grid">
|
<ul role="list" className="link-card-grid">
|
||||||
{filteredCards.map(({ url, title, body, tag }, i) => (
|
{filteredCards.map(({ url, title, body, tag, "date-added": dateAdded }, i) => (
|
||||||
<Card
|
<Card
|
||||||
key={`${title}-${i}`}
|
key={`${title}-${i}`}
|
||||||
href={url}
|
href={url}
|
||||||
title={title}
|
title={title}
|
||||||
body={body}
|
body={body}
|
||||||
tag={tag}
|
tag={tag}
|
||||||
|
dateAdded={dateAdded}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
box-shadow: inset 0px -1px 0px var(--border-muted);
|
box-shadow: inset 0px -1px 0px var(--border-muted);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
|
/* scrollbar-width: none; /* Firefox */
|
||||||
|
/* -ms-overflow-style: none; /* Internet Explorer and Edge */
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
background-color: var(--background);
|
background-color: var(--background);
|
||||||
@@ -13,12 +15,7 @@
|
|||||||
z-index: 999999;
|
z-index: 999999;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* hide scrollbar
|
/* Hide scrollbar for Chrome, Safari and Opera */
|
||||||
.category-nav {
|
/* .category-nav::-webkit-scrollbar {
|
||||||
scrollbar-width: none;
|
|
||||||
-ms-overflow-style: none;
|
|
||||||
}
|
|
||||||
.category-nav::-webkit-scrollbar{
|
|
||||||
display: none;
|
display: none;
|
||||||
}
|
} */
|
||||||
*/
|
|
||||||
|
|||||||
Reference in New Issue
Block a user