chore: restore now page articles

This commit is contained in:
Cory Dransfeldt 2023-09-26 16:29:37 -07:00
parent 6c97dc89e7
commit 6d258fc463
No known key found for this signature in database
5 changed files with 55 additions and 1 deletions

3
.env
View file

@ -4,4 +4,5 @@ API_KEY_WEBMENTIONS_CORYD_DEV=
SITE_ID_CLICKY=
SITE_KEY_CLICKY=
SECRET_FEED_ALBUM_RELEASES=
SECRET_FEED_GOODREADS=
SECRET_FEED_GOODREADS=
SECRET_FEED_INSTAPAPER_LIKES=

24
src/_data/articles.js Normal file
View file

@ -0,0 +1,24 @@
const Parser = require('rss-parser')
const { AssetCache } = require('@11ty/eleventy-fetch')
module.exports = async function () {
const parser = new Parser()
const url = process.env.SECRET_FEED_INSTAPAPER_LIKES
const asset = new AssetCache('articles_data')
if (asset.isCacheValid('1h')) return await asset.getCachedValue()
const res = await parser.parseURL(url).catch((error) => {
console.log(error.message)
})
const articles = res.items.map((item) => {
return {
title: item['title'],
date: item['pubDate'],
summary: item['description'],
url: item['link'],
id: item['guid'],
type: 'article',
}
})
await asset.save(articles, 'json')
return articles
}

View file

@ -6,6 +6,7 @@ layout: main
{% render "partials/now/media-grid.liquid", data:artists, icon: "microphone-2", title: "Artists", shape: "square", count: 8, loading: 'eager' %}
{% render "partials/now/media-grid.liquid", data:albums, icon: "vinyl", title: "Albums", shape: "square", count: 8, loading: 'lazy' %}
{% render "partials/now/albumReleases.liquid", albumReleases:albumReleases %}
{% render "partials/now/articles.liquid", articles:articles %}
{% render "partials/now/media-grid.liquid", data:books, icon: "books", title: "Books", shape: "vertical", count: 6, loading: 'lazy' %}
{% render "partials/now/media-grid.liquid", data:movies, icon: "movie", title: "Movies", shape: "vertical", count: 6, loading: 'lazy' %}
{% render "partials/now/media-grid.liquid", data:tv, icon: "device-tv", title: "TV", shape: "vertical", count: 6, loading: 'lazy' %}

View file

@ -0,0 +1,15 @@
{% if articles.size > 0 %}
<h2 class="[&>svg]:h-5 [&>svg]:w-5 [&>svg]:md:h-7 [&>svg]:md:w-7 [&>svg]:-mt-1 [&>svg]:md:-mt-1.5 [&>svg]:inline icon--bold m-0 text-xl font-black leading-tight tracking-normal dark:text-gray-200 md:text-2xl mt-8 mb-4">
{% tablericon "news" "Articles" %}
Articles
</h2>
<ul class="list-inside list-disc pl-5 md:pl-10">
{% for article in articles limit: 5 %}
<li class="mt-1.5 mb-2">
<a href="{{article.url}}" title="{{article.title | escape}}">
{{ article.title }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}

13
src/feeds/articles.liquid Normal file
View file

@ -0,0 +1,13 @@
---
layout: null
eleventyExcludeFromCollections: true
permalink: /feeds/articles
---
{% render "partials/feeds/rss.liquid"
permalink:"/feeds/articles"
title:"Articles • Cory Dransfeldt"
description:"Articles I've liked recently."
data:articles
updated:articles[0].date
site:site
%}