package
DocPad plugin for loading json/yml/etc. and making it avaliable to documents and layouts. Forked from docpad-plugin-data with several improvements
npm install docpad-plugin-datafilesGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 8 packages.
3.3 MB
Includes dependencies.
DocPad plugin for simple data files.
Loads and parses JSON, YAML, JavaScript, and CoffeeScript files from src/data/ and stores the contents on
config.templateData, which makes the data available as @filename (or {{filename}} or whatever) when rendering
documents and layouts.
Notable features:
file-name.json becomes @fileName.)docpad install datafilesdataPaths: An array of folders to search for data files in.
Relative dataPaths are resolved from docpadConfig.srcPath, which defaults to ./src/.
camelCase: converts file names with spaces, hyphens, etc. to camelCase to enable easier usage in templates.
For example foo-bar.json becomes @fooBar when true vs @['foo-bar'] when false.
alwaysReload: Default behavior is to check the mtime and only reload modified files during regeneration.
When true, this check will be skipped and all files will always be reloaded.
Note that DocPad only watches for changes in folders under docpadConfig.srcPath.
Config with default options in CoffeeScript:
docpadConfig = {
plugins: {
datafiles:
dataPaths: [ 'data' ],
camelCase: true,
alwaysReload: false
}
# ...
}
module.exports = docpadConfigOr JavaScript:
const docpadConfig = {
plugins: {
datafiles: {
dataPaths: ['data'],
camelCase: true
alwaysReload: false
}
}
// ...
};
module.exports = docpadConfig;Original code was forked from docpad-plugin-data. Tests, documentation, various features, and other improvements by Nathan Friedly.