Prefix slides with YAML meta data, configure behaviour based on the meta data.
Simply drop it in as a replacement for bespoke-marked,
var markdown = require('bespoke-meta-markdown');
bespoke.from('article', [
markdown(config)
]);
Default config:
var defaults = {
master: function (slide, value) {
slide.classList.add(value);
}
};
To take advantage of this default behavior insert YAML data in a slide
---
<!--
master: myClass
-->
# title of slide
* bullet
* list
---
To configure your own behavior, simply define methods on the configuration object
var markdown = require('bespoke-meta-markdown');
bespoke.from('article', [
markdown({
copyright: function(slide, info) {
slide.innerHTML += '<p>© ' + info.owner + ' ' + info.year + '</p>';
}
})
]);
To turn off default behaviour set master to null
var markdown = require('bespoke-meta-markdown');
bespoke.from('article', [
markdown({master: null});
]);
The this
context of each configuration method is
the bespoke deck
object, for cases where YAML configuration
could affect all slides:
var markdown = require('bespoke-meta-markdown');
bespoke.from('article', [
markdown({
skip: function (slide, bool) {
if (!bool) {return;}
var deck = this;
deck.slides.splice(deck.slides.indexOf(slide), 1);
deck.parent.removeChild(slide);
}
})
]);
$ npm install bespoke-meta-markdown
As of 1.3.x bespoke-meta-markdown supplies a reload
method which
allows slides loaded from markdown to be reloaded in place, instead
of a full refresh.
The reload
method is supplied on the function object returned
when the exported function is called.
require('bespoke-meta-markdown')
=> function metaMarkdown(config)
=> function bespokePlugin(deck, ...)
#reload function(file, LR)
The idea is to tie it into live reload
var markdown = require('bespoke-meta-markdown');
var md = markdown();
bespoke.from('article', [md]);
LiveReload.addPlugin(MarkdownPlugin)
function MarkdownPlugin(window, host) {
this.window = window;
this.host = host;
}
MarkdownPlugin.prototype.reload = function (path, opts) {
path = path.split('/');
var file = path[path.length-1];
if (file.split('.')[1] !== 'md') { return false; }
md.reload(file, this); //<-- using the bespoke-meta-markdown reload method
return true;
}
This plugin was built with generator-bespokeplugin.