summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@ache.one>2022-12-10 08:15:05 +0100
committerache <ache@ache.one>2022-12-10 08:15:05 +0100
commit88ef31743b7c59214b3bf4aaeef51af3f2fcb8f7 (patch)
treeb747b11c328cb6e4b89d2cede9f7b11d077ca792
parentPut title as underligned (diff)
Show date on each article
-rw-r--r--src/build/index.mjs28
-rw-r--r--src/build/rss.mjs4
-rwxr-xr-xsrc/css/_contenu.scss5
3 files changed, 26 insertions, 11 deletions
diff --git a/src/build/index.mjs b/src/build/index.mjs
index ce490cf..a8fac14 100644
--- a/src/build/index.mjs
+++ b/src/build/index.mjs
@@ -5,31 +5,37 @@ import {h} from 'hastscript';
import {select} from 'hast-util-select';
import {toString as hastToString} from 'mdast-util-to-string';
import cssesc from 'cssesc';
+import toml from '@ltd/j-toml';
import {toHtmlRaw, toString, toMdRaw, mdToHtmlRaw} from './to-html.mjs';
import loadSVG from './load-svg.mjs';
import listArticles from './list-articles.mjs';
import getRSS from './rss.mjs';
-import toml from '@ltd/j-toml';
function getArticleYear(article) {
- if(article.metaData.pubDate.getFullYear) {
+ if (article.metaData.pubDate.getFullYear) {
return article.metaData.pubDate.getFullYear();
- } else if(article.metaData.pubDate.getUTCFullYear) {
+ }
+
+ if (article.metaData.pubDate.getUTCFullYear) {
return article.metaData.pubDate.getUTCFullYear();
}
return 0;
}
+
function getArticleDate(article) {
- if(article.metaData.pubDate.getDate) {
+ if (article.metaData.pubDate.getDate) {
return article.metaData.pubDate.getFullYear() * 100 + article.metaData.pubDate.getDate();
- } else if(article.metaData.pubDate.getUTCDate) {
+ }
+
+ 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);
}
@@ -58,9 +64,7 @@ const loadMD = (listFile, suffix) => {
const logoP = select('source', intro);
if (logoP !== null) {
- console.log(logoP)
- logoP.properties.srcSet= `${suffix}/${logoP.properties.srcSet}`;
- console.log(logoP)
+ logoP.properties.srcSet = `${suffix}/${logoP.properties.srcSet}`;
}
titleHtml.children[0].properties.href = `${suffix}/${file.slice(0, -3)}`;
@@ -73,6 +77,14 @@ const loadMD = (listFile, suffix) => {
readMore.properties.href = `${suffix}/${file.slice(0, -3)}`;
const pubYear = getArticleYear({metaData});
+ if (metaData.pubDate) {
+ try {
+ metaData.pubDateISO = metaData.pubDate.toISOString();
+ } catch (error) {
+ console.error(`Error on file ${file} with pubDate (${metaData.pubDate}): ${error}`);
+ }
+ }
+
listContent.push({
name: file.slice(0, -3),
content: htmlRender,
diff --git a/src/build/rss.mjs b/src/build/rss.mjs
index e890152..04b0393 100644
--- a/src/build/rss.mjs
+++ b/src/build/rss.mjs
@@ -14,8 +14,6 @@ const getRSS = (articles, baseUrl) => {
language: 'fr',
pubDate: (new Date().toLocaleString()),
ttl: '1440',
- // eslint-disable-next-line camelcase
- custom_elements: ['<?xml-stylesheet type="text/css" href="http://localhost:8080/s/css/style.css" ?>'],
});
for (const article of articles.slice(0, 10)) {
@@ -27,7 +25,7 @@ const getRSS = (articles, baseUrl) => {
url: `${baseUrl}articles/${article.name}`,
guid: article.domTitle,
author: 'ache',
- date: article.metaData.pubDate.toISOString(),
+ date: article.metaData.pubDateISO,
categories: article.metaData.tags,
// eslint-disable-next-line camelcase
custom_elements: [
diff --git a/src/css/_contenu.scss b/src/css/_contenu.scss
index 3aa56d1..4dab365 100755
--- a/src/css/_contenu.scss
+++ b/src/css/_contenu.scss
@@ -20,6 +20,10 @@ article {
line-height: 1.6rem;
.pubdate {
+ text-align: right;
+ font-size: 0.75em;
+ color: #999;
+ /*
position: absolute;
top: 0;
right: 0;
@@ -29,6 +33,7 @@ article {
overflow: clip;
color: pink;
text-align: right;
+ */
}
ul {
line-height: 1.6;