vanillajs-deck/js/slideLoader.js
2019-11-22 16:37:45 -08:00

25 lines
611 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) {
if (!cycle[next]) {
cycle[next] = true;
const nextSlide = await loadSlide(next);
slides.push(nextSlide);
next = nextSlide.nextSlide;
}
else {
break;
}
}
return slides;
}