1
0
mirror of https://github.com/osmarks/website synced 2024-12-23 16:40:31 +00:00

fix sidenote layout and performance enhancements

This commit is contained in:
osmarks 2024-10-26 15:14:51 +01:00
parent 6011e27dbd
commit d9a3eeae1e
3 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,5 @@
--- ---
title: "Maghammer: My personal data warehouse" title: "Maghammer: my personal data warehouse"
created: 28/08/2023 created: 28/08/2023
updated: 14/05/2024 updated: 14/05/2024
description: Powerful search tools as externalized cognition, and how mine work. description: Powerful search tools as externalized cognition, and how mine work.

View File

@ -402,6 +402,15 @@ window.points = (async () => {
} }
})() })()
// we don't consider things that might be in a <summary> but it is not relevant here
const inCollapsedDetails = el => {
while (el) {
if (el.nodeName === "DETAILS" && el.open === false) return true
el = el.parentElement
}
return false
}
const footnotes = document.querySelector(".footnotes") const footnotes = document.querySelector(".footnotes")
const sidenotes = document.querySelector(".sidenotes") const sidenotes = document.querySelector(".sidenotes")
if (sidenotes && footnotes) { if (sidenotes && footnotes) {
@ -427,7 +436,7 @@ if (sidenotes && footnotes) {
const exclusions = [[-Infinity, Math.max(articleRect.top, snRect.top)]] const exclusions = [[-Infinity, Math.max(articleRect.top, snRect.top)]]
for (const codeblock of codeblocks) { for (const codeblock of codeblocks) {
const codeblockRect = codeblock.getBoundingClientRect() const codeblockRect = codeblock.getBoundingClientRect()
if (codeblockRect.width !== 0) { // collapsed if (codeblockRect.width !== 0 && !inCollapsedDetails(codeblock)) { // collapsed
exclusions.push([codeblockRect.top - BORDER, codeblockRect.top + codeblockRect.height + BORDER]) exclusions.push([codeblockRect.top - BORDER, codeblockRect.top + codeblockRect.height + BORDER])
} }
} }

View File

@ -8,7 +8,7 @@ mixin image(src)
picture picture
each pair in src each pair in src
if pair[0] == "_fallback" if pair[0] == "_fallback"
img(src=pair[1]) img(src=pair[1], loading="lazy")
else else
source(srcset=pair[1], type=pair[0]) source(srcset=pair[1], type=pair[0])