mirror of
https://github.com/JeremyLikness/vanillajs-deck
synced 2024-11-14 09:34:55 +00:00
25 lines
634 B
JavaScript
25 lines
634 B
JavaScript
import { Slide } from "./slide.js"
|
|
|
|
async function loadSlide(slideName) {
|
|
const response = await fetch(`./slides/${slideName}.html`);
|
|
const slide = await response.text();
|
|
return new Slide(slide);
|
|
}
|
|
|
|
export async function loadSlides(start) {
|
|
var next = start;
|
|
const slides = [];
|
|
const cycle = {};
|
|
while (next) {
|
|
const nextSlide = await loadSlide(next);
|
|
if (!cycle[nextSlide.title]) {
|
|
slides.push(nextSlide);
|
|
cycle[nextSlide.title] = nextSlide;
|
|
next = nextSlide.nextSlide;
|
|
}
|
|
else {
|
|
break;
|
|
}
|
|
}
|
|
return slides;
|
|
} |