-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added an automatically generated study guide
- Loading branch information
Michael Greenburg
committed
Apr 25, 2024
1 parent
923404b
commit 832350a
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,4 +66,5 @@ titles_from_headings: | |
header_pages: | ||
- resources.md | ||
- syllabus.md | ||
- lessons.md | ||
- lessons.md | ||
- study-guide.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Study Guide | ||
|
||
<div id="study-guide"></div> | ||
|
||
<script> | ||
const lessonPages = ['lessons/1.html', | ||
'lessons/2.html', | ||
'lessons/3.html', | ||
'lessons/4.html', | ||
'lessons/5.html', | ||
'lessons/6.html', | ||
'lessons/7.html', | ||
'lessons/8.html', | ||
'lessons/9.html', | ||
'lessons/10.html', | ||
'lessons/11.html', | ||
'lessons/12.html', | ||
'lessons/13.html', | ||
]; | ||
|
||
async function generateStudyGuide() { | ||
const studyGuideContainer = document.getElementById('study-guide'); | ||
|
||
for (const lessonPath of lessonPages) { | ||
try { | ||
const response = await fetch(lessonPath); | ||
const text = await response.text(); | ||
const parser = new DOMParser(); | ||
const doc = parser.parseFromString(text, 'text/html'); | ||
const studyGuideSection = doc.querySelector('h2#study-guide + ul'); | ||
if (studyGuideSection) { | ||
const lessonNumber = lessonPages.indexOf(lessonPath) + 1; | ||
const lessonHeader = `<h3><a href="${lessonPath}">Lesson ${lessonNumber}</a></h3>`; | ||
studyGuideContainer.innerHTML += lessonHeader; | ||
studyGuideContainer.appendChild(studyGuideSection.cloneNode(true)); } | ||
} catch (error) { | ||
console.error("Error fetching or parsing lesson:", lessonPath, error); | ||
} | ||
} | ||
} | ||
|
||
generateStudyGuide(); | ||
</script> |