Skip to content

Commit

Permalink
Add feature to set reveal.js options with CLI args
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Nov 11, 2023
1 parent be7a1a8 commit 3c5f240
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions bin/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Options:
--css <files> CSS files to inject into the page
--scripts <files> Scripts to inject into the page
--assets-dir <dirname> Defines assets directory name [default: _assets]
--view scroll Use reveal.js scroll view feature [default: undefined]
--preprocessor <script> Markdown preprocessor script
--template <filename> Template file for reveal.js
--listing-template <filename> Template file for listing
Expand Down
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const getSlideOptions = options => {
};

export const getRevealOptions = options => {
return _.defaults({}, options, revealConfig);
return _.defaults({}, options, revealConfig, cliConfig);
};

export const getThemeUrl = (theme, assetsDir, base) => {
Expand Down
7 changes: 4 additions & 3 deletions test/render.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('should render basic template', async () => {
);
assert(actual.includes('<script src="/dist/reveal.js"></script>'));
assert(actual.includes('<script src="/plugin/markdown/markdown.js"></script>'));
assert(actual.includes('var options = extend(defaultOptions, {}, queryOptions);'));
assert(actual.includes('var options = extend(defaultOptions, {"_":[]}, queryOptions);'));
});

test('should render markdown content', async () => {
Expand Down Expand Up @@ -65,7 +65,8 @@ test('should render root-based domain-less links for static markup', async () =>

test('should render reveal.js options', async () => {
const actual = await render('', { revealOptions: { controls: false } });
assert(actual.includes('var options = extend(defaultOptions, {"controls":false}, queryOptions);'));
console.log(actual);
assert(actual.includes('var options = extend(defaultOptions, {"controls":false,"_":[]}, queryOptions);'));
});

test('should render title from YAML front matter', async () => {
Expand Down Expand Up @@ -104,7 +105,7 @@ test('should use preprocesser for markdown', async () => {
test('should merge revealOptions from front matter and local options', async () => {
const revealOptions = { height: 100, transition: 'none' };
const actual = await render('---\nrevealOptions:\n width: 300\n height: 500\n---\nSlide', { revealOptions });
const expected = JSON.stringify(Object.assign({}, revealOptions, { width: 300, height: 500 }));
const expected = JSON.stringify(Object.assign({}, revealOptions, { _: [] }, { width: 300, height: 500 }));
assert(actual.includes(`var options = extend(defaultOptions, ${expected}, queryOptions);`));
});

Expand Down

0 comments on commit 3c5f240

Please sign in to comment.