summaryrefslogtreecommitdiff
path: root/src/build/article.mjs
diff options
context:
space:
mode:
authorache <ache@ache.one>2023-04-22 00:08:23 +0200
committerache <ache@ache.one>2023-04-22 00:08:23 +0200
commite089388ab53d8e015f0cc997b3cee0fb1d62bca6 (patch)
tree677567c50de3cfa03bcd383ac558a980d4412bc5 /src/build/article.mjs
parentReplace the mamooth (diff)
Support for multilang
Diffstat (limited to 'src/build/article.mjs')
-rw-r--r--src/build/article.mjs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/build/article.mjs b/src/build/article.mjs
new file mode 100644
index 0000000..1a7b09b
--- /dev/null
+++ b/src/build/article.mjs
@@ -0,0 +1,31 @@
+// Set of functions to handle articles
+
+function getArticleYear(article) {
+ if (article.metaData.pubDate.getFullYear) {
+ return article.metaData.pubDate.getFullYear();
+ }
+
+ if (article.metaData.pubDate.getUTCFullYear) {
+ return article.metaData.pubDate.getUTCFullYear();
+ }
+
+ return 0;
+}
+
+function getArticleDate(article) {
+ if (article.metaData.pubDate.getDate) {
+ return article.metaData.pubDate.getFullYear() * 100 + article.metaData.pubDate.getDate();
+ }
+
+ if (article.metaData.pubDate.getUTCDate) {
+ return article.metaData.pubDate.getUTCFullYear() * 100 + article.metaData.pubDate.getDate();
+ }
+
+ return 0;
+}
+
+function cmpArticles(a, b) {
+ return getArticleDate(b) - getArticleDate(a);
+}
+
+export {getArticleDate, getArticleYear, cmpArticles};