Skip to content

Commit

Permalink
Added an automatically generated study guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Greenburg committed Apr 25, 2024
1 parent 923404b commit 832350a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
3 changes: 2 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ titles_from_headings:
header_pages:
- resources.md
- syllabus.md
- lessons.md
- lessons.md
- study-guide.md
43 changes: 43 additions & 0 deletions study-guide.md
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>

0 comments on commit 832350a

Please sign in to comment.