Skip to content

Commit

Permalink
Fetch rss from status.lol, display on readme
Browse files Browse the repository at this point in the history
  • Loading branch information
RickCogley committed Nov 19, 2024
1 parent 606af28 commit fa37d83
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Many thanks to [Óscar Otero](https://oscarotero.com/), creator of Lume, [Lume C
| Item | Value |
| --- | --- |
| Total Files | 163 |
| Repo Size in MB | 16 |
| Repo Size in MB | 83 |

41 changes: 41 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/_data.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Simple constants
export const cacheBuster = `${new Date().getTime()}`;
export const todaysDateYYYYMMDD = `${new Date().toISOString().split("T")[0]}`;

Expand All @@ -6,6 +7,7 @@ export const todaysDateYYYYMMDD = `${new Date().toISOString().split("T")[0]}`;
export const todaysDateJAJP = `${new Date().toLocaleString('ja-JP',{ year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' })}`;
export const todaysDateENUS = `${new Date().toLocaleString('en-US',{ year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' })}`;

// Fetch holidays
const response = await fetch('https://holidays-jp.github.io/api/v1/date.json', {
method: 'GET',
mode: 'no-cors',
Expand All @@ -19,6 +21,7 @@ export {
holidays,
};

// Get repo folder size
import { join } from "https://deno.land/std/path/mod.ts";

async function getFolderSize(path: string): Promise<number> {
Expand All @@ -45,6 +48,27 @@ getFolderSize(folderPath).then(size => {
export const repoSizeLong = await getFolderSize(folderPath);
export const repoSizeMB = Math.trunc(repoSizeLong/1024/1024);

// Shuffle
// https://en.wikipedia.org/wiki/Fisher-Yates_shuffle
import shuffle from "https://deno.land/x/shuffle/mod.ts";
console.log(shuffle(["i","ro","ha","ni","ho","he","to"]));

// Import rss feed and convert to json
import { parseFeed } from "https://deno.land/x/rss/mod.ts";
async function fetchAndConvertRSS(url: string, limit: number) {
// Fetch the RSS feed
const response = await fetch(url);
const xml = await response.text();
// Parse the RSS feed
const feed = await parseFeed(xml);
// Limit the number of entries
const limitedEntries = feed.entries.slice(0, limit);
// Convert to JSON
// const json = JSON.stringify( {...feed, entries: limitedEntries }, null, 2);
const json = { ...feed, entries: limitedEntries };
return json;
}
const rssUrl = "https://rick.status.lol/feed/rss";
const limit = 5;
fetchAndConvertRSS(rssUrl,limit).then(console.log).catch(console.error);
export const statuses = await fetchAndConvertRSS(rssUrl,limit);
9 changes: 9 additions & 0 deletions src/repo-readme.vto
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,19 @@ Many thanks to [Óscar Otero](https://oscarotero.com/), creator of Lume, [Lume C
- Icons: from [Phosphor](https://phosphoricons.com/)
- CSS base library: [Tachyons](https://tachyons.io/)

## Latest Statuses:

{{ for item of statuses.entries }}* [{{ item.description.value }}]({{ item.id }})
{{ /for }}

## Stats:

| Item | Value |
| --- | --- |
| Total Files | {{ search.files("").length }} |
| Repo Size in MB | {{ repoSizeMB }} |





0 comments on commit fa37d83

Please sign in to comment.