From c01019e351c16fc85d198fd6e8914eaa0bc51759 Mon Sep 17 00:00:00 2001 From: Chris Manson Date: Mon, 29 Apr 2024 14:47:58 +0100 Subject: [PATCH] theme provided config for initialize This allows a theme to provide a config.json to add to or override variables passed to initialise --- src/main.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 7842a99..d7ca211 100644 --- a/src/main.js +++ b/src/main.js @@ -36,11 +36,24 @@ document.querySelector('.slides').innerHTML = sections.join(''); const deck = new Reveal(); -deck.initialize({ +const defaultConfig = { hash: true, width: 1280, height: 960, margin: 0.1, highlight: {}, plugins: [Markdown, Highlight, Notes], -}); +}; + +let themeConfig = {}; + +try { + const findingConfig = import.meta.glob('@theme/config.json', {eager: true}); + const [filename] = Object.keys(findingConfig); + + if (filename) { + themeConfig = findingConfig[filename] + } +} catch {} + +deck.initialize({...defaultConfig, ...themeConfig});