diff --git a/main.ts b/main.ts
index 32b9b90..88cad0f 100644
--- a/main.ts
+++ b/main.ts
@@ -1,5 +1,8 @@
import { DOMParser } from "jsr:@b-fuze/deno-dom";
+const ARTICLES_ID_MIN = 87;
+const ARTICLES_ID_MAX = 88;
+
const downloadDate = new Date();
type ArticleInfo = {
@@ -132,6 +135,42 @@ function renderIndex(articles: ArticleInfo[]): string {
);
}
+const datesTemplate = await Deno.readTextFile("templates/dates.html");
+
+function renderDateIndex(articles: ArticleInfo[]): string {
+ return datesTemplate
+ .slice()
+ .replaceAll("$downloadDate", downloadDate.toUTCString())
+ .replaceAll(
+ "$articleEntriesByDate",
+ articles
+ .toSorted((a, b) =>
+ new Date(a.dateAdded).getTime() -
+ new Date(b.dateAdded).getTime()
+ )
+ .map((article) => `
+
+
+
+ ${article.title}
+
+ |
+ ${article.author} |
+ ${
+ new Date(article.dateAdded).toUTCString()
+ } |
+ ${(
+ article.tags.map((tag) => `
+
+ ${tag}
+
+ `).join(", ")
+ )} |
+
+ `).join(""),
+ );
+}
+
const categoriesTemplate = await Deno.readTextFile("templates/categories.html");
function renderCategories(articles: ArticleInfo[]): string {
@@ -176,8 +215,8 @@ function renderCategories(articles: ArticleInfo[]): string {
await Deno.mkdir("build/articles", { recursive: true });
-const articlesIdMin = 1;
-const articlesIdMax = 87;
+const articlesIdMin = ARTICLES_ID_MIN;
+const articlesIdMax = ARTICLES_ID_MAX;
const articles: ArticleInfo[] = [];
for (let id = articlesIdMin; id <= articlesIdMax; ++id) {
@@ -205,6 +244,12 @@ console.log("Building index...");
const indexHtml = renderIndex(articles);
await Deno.writeTextFile("build/articles/index.html", indexHtml);
console.log("Index written to 'build/articles/index.html'!");
+
+console.log("Building date index...");
+const dateIndexHtml = renderDateIndex(articles);
+await Deno.writeTextFile("build/articles/dates.html", dateIndexHtml);
+console.log("Date index written to 'build/articles/dates.html'!");
+
console.log("Building categories...");
const categoriesHtml = renderCategories(articles);
await Deno.writeTextFile("build/articles/categories.html", categoriesHtml);
diff --git a/static/articles/style.css b/static/articles/style.css
index 10476b5..6e1604a 100644
--- a/static/articles/style.css
+++ b/static/articles/style.css
@@ -20,6 +20,10 @@ table {
border-collapse: collapse;
}
+td {
+ padding: 5px;
+}
+
td.article-date {
white-space: nowrap;
}
diff --git a/templates/categories.html b/templates/categories.html
index a32b97f..abca1ea 100644
--- a/templates/categories.html
+++ b/templates/categories.html
@@ -4,7 +4,7 @@
-
+
@@ -16,6 +16,7 @@
diff --git a/templates/dates.html b/templates/dates.html
new file mode 100644
index 0000000..8b1787d
--- /dev/null
+++ b/templates/dates.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Articles sorted by dates (first to last)
+
+ The articles were downloaded $downloadDate.
+
+
+ Title |
+ Author |
+ Date added |
+ Tags |
+
+ $articleEntriesByDate
+
+
+
+
diff --git a/templates/index.html b/templates/index.html
index 7b97a7d..e631356 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -20,8 +20,10 @@
The articles were downloaded $downloadDate.
- See also the articles organized by categories.
+ See also the articles organized
+ by categories
+ or
+ by dates.