mirror of
https://github.com/HananoshikaYomaru/openfreebooks.git
synced 2026-11-13 13:05:51 +00:00
Update chapter weight for directed numbers section, modify curriculum structure to include a new basic math notation category, and enhance frontend logic for rendering math content in widget-less chapters.
This commit is contained in:
parent
dc3f9d193b
commit
b4817dd748
6 changed files with 1031 additions and 7 deletions
|
|
@ -36,11 +36,23 @@ function mountFooterYear() {
|
|||
}
|
||||
}
|
||||
|
||||
function scheduleChapterMath() {
|
||||
void import("./lib/render-math").then(({ renderBookMath }) => {
|
||||
requestAnimationFrame(() => renderBookMath());
|
||||
});
|
||||
}
|
||||
|
||||
function mountChapterWidgets() {
|
||||
const article = document.querySelector<HTMLElement>("[data-chapter]");
|
||||
const chapterKey = article?.dataset.chapter;
|
||||
const mounts = document.querySelectorAll<HTMLElement>("[data-widget]");
|
||||
if (!chapterKey || mounts.length === 0) return;
|
||||
if (!article || !chapterKey) return;
|
||||
|
||||
// KaTeX must run on widget-less chapters too (renderBookMath was only chained after widgets).
|
||||
if (mounts.length === 0) {
|
||||
scheduleChapterMath();
|
||||
return;
|
||||
}
|
||||
|
||||
void import("./generated/chapter-widgets").then(({ chapterWidgetLoaders }) => {
|
||||
const loadPromises: Promise<void>[] = [];
|
||||
|
|
@ -62,10 +74,7 @@ function mountChapterWidgets() {
|
|||
}
|
||||
|
||||
void Promise.all(loadPromises).then(() => {
|
||||
if (!document.querySelector(".book-prose")) return;
|
||||
void import("./lib/render-math").then(({ renderBookMath }) => {
|
||||
requestAnimationFrame(() => renderBookMath());
|
||||
});
|
||||
scheduleChapterMath();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue