drizzle-builder
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -8,12 +8,63 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; // TODO NOPE | ||
var _object = require('./object'); | ||
var deepCollection = _object.deepCollection; | ||
// TODO NOPE | ||
var _shared = require('./shared'); | ||
var resourcePath = _shared.resourcePath; | ||
var _path = require('path'); | ||
var path = _interopRequireDefault(_path).default; | ||
var _ramda = require('ramda'); | ||
var pathSatisfies = _ramda.pathSatisfies; | ||
var is = _ramda.is; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** | ||
* This will return a relative URL prefix for a given resource (anything being | ||
* output to an HTML file). | ||
* | ||
* The purpose of this to value is to be assigned to the `{{baseurl}}` template | ||
* context property, for use in relative URLs within the HTML. | ||
* | ||
* This relative path is determined by the path-based ID of the resource (e.g. | ||
* patterns.components.button) and the `dest` configration settings for the | ||
* `resourceType` of the supplied resource (e.g. 'page', 'pattern'). | ||
* | ||
* @param {Object} resource | ||
* @param {Object} drizzleData | ||
* @return {String} | ||
* | ||
* @example | ||
* getBaseUrl(somePageResource, drizzleData); | ||
* // '../..' | ||
*/ | ||
function getBaseUrl(resource, drizzleData) { | ||
var options = drizzleData.options; | ||
var destRoot = options.dest.root; | ||
var destResource = options.dest[Object.keys(options.keys).find(function (key) { | ||
return options.keys[key].singular === resource.resourceType; | ||
})]; | ||
var baseurl = path.relative(path.dirname(resourcePath(resource.id, destResource)), destRoot); | ||
return baseurl === '' ? '.' + baseurl : baseurl; | ||
} | ||
function resourceContext(resource, drizzleData) { | ||
var context = Object.assign({}, resource); | ||
context.drizzle = drizzleData; | ||
if (pathSatisfies(is(String), ['dest', 'root'], drizzleData.options)) { | ||
context.baseurl = getBaseUrl(resource, drizzleData); | ||
} | ||
if (_typeof(resource.data) === 'object') { | ||
@@ -20,0 +71,0 @@ Object.keys(resource.data).map(function (dataKey) { |
{ | ||
"name": "drizzle-builder", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "The builder for Drizzle", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91649
2241