Skip to content

Commit

Permalink
Merge pull request #30 from allegro/blog-posts-fix
Browse files Browse the repository at this point in the history
Changed blog post fetching from RSS to HTML scraping
  • Loading branch information
alicja-raczkowska authored Aug 29, 2024
2 parents 311dc6b + 811cef8 commit 37114ce
Show file tree
Hide file tree
Showing 5 changed files with 718 additions and 126 deletions.
33 changes: 11 additions & 22 deletions components/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,58 +13,47 @@ import { enUS } from 'date-fns/locale'
export interface IPost {
guid: string;
title: string;
categories: string[];
authors: { author: IAuthor[] };
authors: IAuthor[];
link: string;
pubDate: string;
contentSnippet: string;
thumbnail: string;
}

export interface IAuthor {
name: string[];
photo: string[];
url: string[];
name: string;
photo: string;
url: string;
}

type PostProps = IPost

const Post: React.FunctionComponent<PostProps> = ({ title, categories, pubDate, contentSnippet, link, authors, thumbnail }) => {
const Post: React.FunctionComponent<PostProps> = ({ title, pubDate, contentSnippet, link, authors }) => {
return (
<article className="m-margin-bottom_16 m-display-flex m-flex-column m-flex-grow_1">
<a href={link} title={title}>
<img width="388" src={thumbnail} alt={title} className="m-display-block m-width-fluid"/>
</a>
<Card className="m-display-flex m-flex-column m-flex-grow_1 m-padding-bottom-0">
<a href={link} title={title} className="m-text-decoration_none">
<Heading size="medium" maxLines={2}>{title}</Heading>
</a>
<Typography as="time" className="m-padding-bottom-16">
{formatDistance(new Date(pubDate), new Date(), { locale: enUS, addSuffix: true })}
</Typography>
<List>
{categories.map(category => (
<List.Item key={category} className="m-margin-right-8 m-display-inline-block">
<Link href={`https://twitter.com/hashtag/${category}`}>#{category}</Link>
</List.Item>
))}
</List>
<Typography className="m-flex-grow-1 m-padding-top-16">
{contentSnippet.split(' ').slice(0, 25).join(' ') + '…'}
</Typography>
<div className="m-display-flex m-flex-justify-between m-padding-top-16 m-flex-items_center">
<div className="m-display-flex m-flex-items_center">
<AvatarGroup max={2} className={`m-padding-right_16 ${styles.avatars}`}>
{authors.author.map((author: IAuthor) => (
<Avatar key={author.name[0]}
alt={author.name[0]}
src={author.photo[0]}
{authors.map((author: IAuthor) => (
<Avatar key={author.name}
alt={author.name}
src={author.photo}
imgProps={{ width: 32, height: 32 }}
/>
))}
</AvatarGroup>
<Link href={authors.author[0].url[0]}>
{authors.author.length > 1 ? authors.author[0].name + '…' : authors.author.map((author: IAuthor) => author.name).join("")}
<Link href={authors[0].url}>
{authors.length > 1 ? authors[0].name + '…' : authors.map((author: IAuthor) => author.name).join("")}
</Link>
</div>
<Link href={`${link}#disqus_thread`}>0 Comments</Link>
Expand Down
2 changes: 1 addition & 1 deletion data/publications.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"publications": [
{
{
"authors": "Roman Dušek, Aleksander Wawer, Christopher Galias, Lidia Wojciechowska",
"date": "2023",
"paper_url": "https://annals-csis.org/Volume_35/drp/7569.html",
Expand Down
Loading

0 comments on commit 37114ce

Please sign in to comment.