Skip to content

Commit 31ac42e

Browse files
authored
Merge pull request FiQCI#135 from FiQCI/master
Hide old calls from home page
2 parents bcf8f01 + 993ee14 commit 31ac42e

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/components/BlogCards.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import '@cscfi/csc-ui-react/css/theme.css';
33
import { CCard, CIcon, CCardContent } from '@cscfi/csc-ui-react';
44
import { mdiArrowRight } from '@mdi/js';
55
import { prependBaseURL } from '../utils/url';
6+
import { hideOldCalls } from '../utils/resourceCalls';
67

78
export const BlogCardComponent = props => {
89
const type = props?.filters?.Type;
@@ -31,7 +32,7 @@ export const BlogCards = () => {
3132
<div className="min-[2600px]:mx-auto min-[2600px]:max-w-[50vw]">
3233

3334
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-6">
34-
{ SITE.publications.slice(-4).reverse().map(blog => <BlogCardComponent {...blog} />) }
35+
{ hideOldCalls(SITE.publications).slice(-4).reverse().map(blog => <BlogCardComponent {...blog} />) }
3536
</div>
3637
<div className="mt-4">
3738
<a

src/components/Blogs.jsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
CCardTitle, CCardContent, CCardActions
66
} from '@cscfi/csc-ui-react';
77
import { BlogCardComponent } from './BlogCards';
8-
import { isResourceCall, newestResourceCall } from '../utils/resourceCalls';
8+
import { hideOldCalls } from '../utils/resourceCalls';
99

1010
const filterStyles = {
1111
"--_c-checkbox-color": " #004E84",
@@ -178,12 +178,6 @@ const BlogsList = ({ id, title, blogs, paginationOptions, handlePageChange, show
178178
);
179179
};
180180

181-
//Keep only the most recent resource call, drop the older ones
182-
const hideOldCalls = blogs => {
183-
const newest = newestResourceCall(blogs, blog => blog.filters?.Type);
184-
return blogs.filter(blog => !isResourceCall(blog.filters?.Type) || blog === newest);
185-
};
186-
187181
//Full blogs component
188182
export const Blogs = () => {
189183
const blogs_dict = hideOldCalls(SITE.publications.filter(blog => blog.hidden != "true"))

src/utils/resourceCalls.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ export const newestResourceCall = (items, getType = item => item.type) =>
1313
items
1414
.filter(item => isResourceCall(getType(item)))
1515
.reduce((latest, item) => (!latest || parseSiteDate(item.date) >= parseSiteDate(latest.date) ? item : latest), null);
16+
17+
//Keep only the most recent resource call, drop the older ones
18+
export const hideOldCalls = publications => {
19+
const newest = newestResourceCall(publications, publication => publication.filters?.Type);
20+
return publications.filter(publication => !isResourceCall(publication.filters?.Type) || publication === newest);
21+
};

0 commit comments

Comments
 (0)