Skip to content

Commit e7dc3d0

Browse files
committed
[home] blog posts
1 parent e5454c8 commit e7dc3d0

File tree

5 files changed

+116
-9
lines changed

5 files changed

+116
-9
lines changed

package-lock.json

Lines changed: 48 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"@astrojs/check": "^0.9.4",
1414
"@astrojs/markdown-remark": "^6.3.7",
1515
"@astrojs/react": "^4.4.0",
16-
"@astropub/md": "^1.0.0",
1716
"@cospired/i18n-iso-languages": "^4.2.0",
1817
"@iconify-json/bi": "^1.2.6",
1918
"@iconify-json/ph": "^1.2.2",
@@ -26,6 +25,7 @@
2625
"marked": "^16.3.0",
2726
"prettier": "^3.6.2",
2827
"prettier-plugin-astro": "^0.14.1",
28+
"rss-parser": "^3.13.0",
2929
"sass": "^1.93.2",
3030
"typescript": "^5.9.2"
3131
},

src/components/BlogRSS.astro

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
import { identity } from "lodash-es";
3+
import Parser from "rss-parser";
4+
5+
const feedUrl = "https://gephi.wordpress.com/feed/";
6+
7+
const parser = new Parser<{ [key: string]: any }, { "media:thumbnail"?: { $: { url: string } } }>({
8+
timeout: 2000,
9+
customFields: {
10+
item: ["media:thumbnail"],
11+
},
12+
});
13+
const feed = await parser.parseURL(feedUrl);
14+
15+
const dateFormatter = new Intl.DateTimeFormat("en-EN", { dateStyle: "long" });
16+
---
17+
18+
<section class="blog-posts">
19+
<h2>Latest posts on Gephi's blog</h2>
20+
<div class="d-flex flex-wrap gap-4 w-100">
21+
{
22+
feed.items.slice(0, 4).map((item) => (
23+
<article class="blog-post">
24+
{" "}
25+
{item["media:thumbnail"] && <img src={item["media:thumbnail"]?.$.url} />}
26+
<a href={item.link}>
27+
<h4>{item.title}</h4>
28+
</a>
29+
<div>{item.contentSnippet}</div>
30+
<div class="text-end text-muted">
31+
by{" "}
32+
{[item.creator, item.pubDate && dateFormatter.format(new Date(item.pubDate))].filter(identity).join(" on ")}
33+
</div>
34+
</article>
35+
))
36+
}
37+
</div>
38+
</section>

src/pages/index.astro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { Image } from "astro:assets";
33
44
import { Icon } from "astro-icon/components";
5+
import BlogRSS from "../components/BlogRSS.astro";
56
import DownloadGephiDesktop from "../components/DownloadGephiDesktop.astro";
67
import Layout from "../layouts/Layout.astro";
78
---
@@ -226,5 +227,8 @@ import Layout from "../layouts/Layout.astro";
226227
</div>
227228
</section>
228229
</section>
230+
<section>
231+
<BlogRSS />
232+
</section>
229233
</main>
230234
</Layout>

src/styles/_contents.scss

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,28 @@ a.no-decoration {
245245
text-decoration: none;
246246
color: inherit;
247247
}
248+
249+
.blog-posts {
250+
.blog-post {
251+
width: calc(50% - 1.5rem / 2);
252+
253+
@include media-breakpoint-down(md) {
254+
width: 100%;
255+
}
256+
257+
@extend .p-4;
258+
@extend .shadow;
259+
background: #fffffff6;
260+
position: relative;
261+
262+
display: flex;
263+
flex-direction: column;
264+
justify-content: space-between;
265+
row-gap: 0.5rem;
266+
img {
267+
max-width: 100%;
268+
max-height: 50%;
269+
object-fit: contain;
270+
}
271+
}
272+
}

0 commit comments

Comments
 (0)