Easy shortcodes for DocPad using shortcode-parser
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
package.json
shortcodeparser.plugin.js

README.md

docpad-plugin-shortcodeparser

Easy shortcodes for DocPad using shortcode-parser.

Usage

1. Add Shortcodes

To add shortcodes, edit your docpad.js-file to include a custom configuration for shortcodeparser:

module.exports = {
	shortcodeparser: {
		codes: [
			// [img src="path.png" alt="text"] becomes <img src="path.png" alt="text" />
			{
				tag: 'img',
				cb: function(buf, opts, templateData) {
					return '<img src="' + opts.src + '" alt="' + opts.alt + '" />';
				}
			},

			// [b]Bold text![/b] becomes <strong>Bold text!</strong>
			{
				tag: 'b',
				cb: function(buf, opts, templateData) {
					return '<strong>' + buf + '</strong>';
				}
			}
		]
	}
};

2. Use File Extensions

Now you can use shortcodes, for example, in your markdown-documents by adjusting the file-extension to "document-name.html.md.sc". You can also set a custom file-extension in your docpad.js-file by setting the key shortcodeparser.extension.