summaryrefslogtreecommitdiff
path: root/src/build/index.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'src/build/index.mjs')
-rw-r--r--src/build/index.mjs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/build/index.mjs b/src/build/index.mjs
index 84d4d9a..f9a0d51 100644
--- a/src/build/index.mjs
+++ b/src/build/index.mjs
@@ -1,8 +1,10 @@
import fs from 'node:fs';
import mustache from 'mustache';
import {u} from 'unist-builder';
+import {h} from 'hastscript';
import {select} from 'hast-util-select';
import {toString as hastToString} from 'mdast-util-to-string';
+import cssesc from 'cssesc';
import {toHtmlRaw, toString} from './to-html.mjs';
import loadSVG from './load-svg.mjs';
@@ -16,20 +18,31 @@ const loadMD = (listFile, suffix) => {
const htmlContent = toHtmlRaw(content);
const htmlRender = toString(htmlContent);
+ const articleHtml = select('article', htmlContent);
const titleHtml = select('h1', htmlContent);
const intro = select('p', htmlContent);
const logo = select('img', htmlContent);
logo.properties.src = `${suffix}/${logo.properties.src}`;
+ logo.properties.height = '150px';
+ logo.properties.width = '150px';
titleHtml.children[0].properties.href = `${suffix}/${file.slice(0, -3)}.html`;
const title = hastToString(titleHtml);
- const domTitle = title.replace(/\s+/g, '-').toLowerCase(); // Maybe encodeURI
+ const domTitle = cssesc(title.replace(/\s+/g, '-').replace(/[\'\"#@]/, '').toLowerCase()); // Maybe encodeURI
+ console.log(domTitle);
+
console.log(`Create : ${title}`);
+ const readMore = h('a', 'Lire plus...');
+
+ readMore.properties.href = `${suffix}/${file.slice(0, -3)}.html`
+ readMore.properties.role = 'expend';
+ readMore.properties.for = domTitle;
+
listContent.push({
name: file.slice(0, -3),
content: htmlRender,
- intro: toString(u('root', [titleHtml, intro])),
+ intro: toString(u('root', [titleHtml, intro, readMore])),
introDesc: hastToString(intro),
imageUrl: logo.properties.src,
title,