diff options
| author | ache <ache@ache.one> | 2026-06-04 06:15:09 +0200 |
|---|---|---|
| committer | ache <ache@ache.one> | 2026-06-04 06:18:14 +0200 |
| commit | 13a9397d18d9369bc541fc83d7fdb2623066fcd8 (patch) | |
| tree | 7d904bc0f465a439e91a325af7c098ad361a018c | |
| parent | Fix footnotes i18n (diff) | |
Fix sidenotes when screen is too short
| -rw-r--r-- | src/build/remove-footnote-header.mjs | 2 | ||||
| -rw-r--r-- | src/js/sidenotes.js | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/build/remove-footnote-header.mjs b/src/build/remove-footnote-header.mjs index 37f3af9..13f9204 100644 --- a/src/build/remove-footnote-header.mjs +++ b/src/build/remove-footnote-header.mjs @@ -8,7 +8,7 @@ export default function specialBox(opt) { return (tree) => { visit(tree, (node, _, parent) => { if (node?.tagName === "h2" && node?.properties?.id === "footnote-label") { - node.tagName = "h4"; + node.tagName = "h3"; node.children = [{ type: "text", value: opt?.title || "Footnote" }]; parent.children.unshift({ diff --git a/src/js/sidenotes.js b/src/js/sidenotes.js index 9519c88..3160c1a 100644 --- a/src/js/sidenotes.js +++ b/src/js/sidenotes.js @@ -22,13 +22,22 @@ const resize = () => { window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; + + // Si la page est trop petite pour afficher les notes dans la marge, on ne fait rien if (sidenote.offsetWidth < 200 || viewportWidth < 1400) { sidenote.innerHTML = ""; return; } - const notes = Array.from(article.querySelectorAll("li")).filter((element) => - element.id.startsWith("user-content-fn"), + const notes = Array.from(article.querySelectorAll("li")).filter( + (element) => { + console.log("🦒", element.innerText); + return ( + element.id.startsWith("user-content-fn") && // If it's a foot-note + !element.innerText.startsWith("http") && // But not a source + !element.innerText.startsWith("Source:") + ); + }, ); const newSidenotes = notes.map((sidenoteLi) => { const div = document.createElement("div"); |