1.0.0 • Published 2 years ago

@dankolz/page-prerun-data-loader v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Page Prerun Data Loader

A plugin for the webhandle framework. Allows a page to request that JSON data files be loaded for use by templates on the page.

Install

npm i @dankolz/page-prerun-data-loader

Usage

When the environment is setup, to use the default directory (data), run:

require('@dankolz/page-prerun-data-loader')()

For any page wishing to load data, they should include something like this in their page json.

{
	"title": "Pre Run Data Loader",
	"dataFiles": [
		{
			"name": "testData",
			"location": "test1.json"
		}
	]
}

The dataFiles section will cause the file data/test1.json to be loaded, parsed as JSON, and put in the variable res.locals.testData.