Fix wrong acces to slide options

If the slide options in the frontmatter are empty
or not present, then slideOptions object in the
parsed JSON is undefined. This triggers an
exception when the sanitized slide options object
is built.

Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
Tilman Vatteroth 2021-02-02 13:27:37 +01:00
parent 78a732abe6
commit 9f59a73049
No known key found for this signature in database
GPG key ID: DEBDB3F34641B019

View file

@ -72,56 +72,57 @@ const defaultOptions = {
// options from yaml meta // options from yaml meta
const meta = JSON.parse($('#meta').text()) const meta = JSON.parse($('#meta').text())
const metaSlideOptions = !!meta && !!meta.slideOptions ? meta.slideOptions : {}
var options = { var options = {
autoPlayMedia: meta.slideOptions.autoPlayMedia, autoPlayMedia: metaSlideOptions.autoPlayMedia,
autoSlide: meta.slideOptions.autoSlide, autoSlide: metaSlideOptions.autoSlide,
autoSlideStoppable: meta.slideOptions.autoSlideStoppable, autoSlideStoppable: metaSlideOptions.autoSlideStoppable,
backgroundTransition: meta.slideOptions.backgroundTransition, backgroundTransition: metaSlideOptions.backgroundTransition,
center: meta.slideOptions.center, center: metaSlideOptions.center,
controls: meta.slideOptions.controls, controls: metaSlideOptions.controls,
controlsBackArrows: meta.slideOptions.controlsBackArrows, controlsBackArrows: metaSlideOptions.controlsBackArrows,
controlsLayout: meta.slideOptions.controlsLayout, controlsLayout: metaSlideOptions.controlsLayout,
controlsTutorial: meta.slideOptions.controlsTutorial, controlsTutorial: metaSlideOptions.controlsTutorial,
defaultTiming: meta.slideOptions.defaultTiming, defaultTiming: metaSlideOptions.defaultTiming,
display: meta.slideOptions.display, display: metaSlideOptions.display,
embedded: meta.slideOptions.embedded, embedded: metaSlideOptions.embedded,
fragmentInURL: meta.slideOptions.fragmentInURL, fragmentInURL: metaSlideOptions.fragmentInURL,
fragments: meta.slideOptions.fragments, fragments: metaSlideOptions.fragments,
hash: meta.slideOptions.hash, hash: metaSlideOptions.hash,
height: meta.slideOptions.height, height: metaSlideOptions.height,
help: meta.slideOptions.help, help: metaSlideOptions.help,
hideAddressBar: meta.slideOptions.hideAddressBar, hideAddressBar: metaSlideOptions.hideAddressBar,
hideCursorTime: meta.slideOptions.hideCursorTime, hideCursorTime: metaSlideOptions.hideCursorTime,
hideInactiveCursor: meta.slideOptions.hideInactiveCursor, hideInactiveCursor: metaSlideOptions.hideInactiveCursor,
history: meta.slideOptions.history, history: metaSlideOptions.history,
keyboard: meta.slideOptions.keyboard, keyboard: metaSlideOptions.keyboard,
loop: meta.slideOptions.loop, loop: metaSlideOptions.loop,
margin: meta.slideOptions.margin, margin: metaSlideOptions.margin,
maxScale: meta.slideOptions.maxScale, maxScale: metaSlideOptions.maxScale,
minScale: meta.slideOptions.minScale, minScale: metaSlideOptions.minScale,
minimumTimePerSlide: meta.slideOptions.minimumTimePerSlide, minimumTimePerSlide: metaSlideOptions.minimumTimePerSlide,
mobileViewDistance: meta.slideOptions.mobileViewDistance, mobileViewDistance: metaSlideOptions.mobileViewDistance,
mouseWheel: meta.slideOptions.mouseWheel, mouseWheel: metaSlideOptions.mouseWheel,
navigationMode: meta.slideOptions.navigationMode, navigationMode: metaSlideOptions.navigationMode,
overview: meta.slideOptions.overview, overview: metaSlideOptions.overview,
parallaxBackgroundHorizontal: meta.slideOptions.parallaxBackgroundHorizontal, parallaxBackgroundHorizontal: metaSlideOptions.parallaxBackgroundHorizontal,
parallaxBackgroundImage: meta.slideOptions.parallaxBackgroundImage, parallaxBackgroundImage: metaSlideOptions.parallaxBackgroundImage,
parallaxBackgroundSize: meta.slideOptions.parallaxBackgroundSize, parallaxBackgroundSize: metaSlideOptions.parallaxBackgroundSize,
parallaxBackgroundVertical: meta.slideOptions.parallaxBackgroundVertical, parallaxBackgroundVertical: metaSlideOptions.parallaxBackgroundVertical,
preloadIframes: meta.slideOptions.preloadIframes, preloadIframes: metaSlideOptions.preloadIframes,
previewLinks: meta.slideOptions.previewLinks, previewLinks: metaSlideOptions.previewLinks,
progress: meta.slideOptions.progress, progress: metaSlideOptions.progress,
rtl: meta.slideOptions.rtl, rtl: metaSlideOptions.rtl,
showNotes: meta.slideOptions.showNotes, showNotes: metaSlideOptions.showNotes,
shuffle: meta.slideOptions.shuffle, shuffle: metaSlideOptions.shuffle,
slideNumber: meta.slideOptions.slideNumber, slideNumber: metaSlideOptions.slideNumber,
theme: meta.slideOptions.theme, theme: metaSlideOptions.theme,
totalTime: meta.slideOptions.totalTime, totalTime: metaSlideOptions.totalTime,
touch: meta.slideOptions.touch, touch: metaSlideOptions.touch,
transition: meta.slideOptions.transition, transition: metaSlideOptions.transition,
transitionSpeed: meta.slideOptions.transitionSpeed, transitionSpeed: metaSlideOptions.transitionSpeed,
viewDistance: meta.slideOptions.viewDistance, viewDistance: metaSlideOptions.viewDistance,
width: meta.slideOptions.width width: metaSlideOptions.width
} || {} } || {}
for (const key in options) { for (const key in options) {