Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

docpad-plugin-datafiles

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docpad-plugin-datafiles

DocPad plugin for loading json/yml/etc. and making it avaliable to documents and layouts. Forked from docpad-plugin-data with several improvements

  • 2.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Weekly downloads
 
Created
Source

docpad-plugin-datafiles

Build Status npm-version

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:

  • Data is cached and only updated when the source file changes
  • Intelligent support for files with spaces, hyphens, etc. in the name (e.g. file-name.json becomes @fileName.)
  • Support for absolute folder paths

Installation

docpad install datafiles

Configuration

dataPaths: 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 = docpadConfig

Or JavaScript:

const docpadConfig = {
  plugins: {
    datafiles: {
      dataPaths: ['data'],
      camelCase: true
      alwaysReload: false
    }
  }
  // ...
};

module.exports = docpadConfig;

Credits

Original code was forked from docpad-plugin-data. Tests, documentation, various features, and other improvements by Nathan Friedly.

Keywords

FAQs

Package last updated on 22 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc