roots-contentful
Advanced tools
Comparing version 0.0.6 to 0.0.7
// Generated by CoffeeScript 1.9.0 | ||
(function() { | ||
var RootsUtil, S, W, contentful, errors, path, pluralize, _; | ||
var RootsUtil, S, W, contentful, errors, path, pluralize, querystring, _; | ||
@@ -19,2 +19,4 @@ _ = require('lodash'); | ||
querystring = require('querystring'); | ||
errors = { | ||
@@ -36,3 +38,3 @@ no_token: 'Missing required options for roots-contentful. Please ensure `access_token` and `space_id` are present.', | ||
return RootsContentful = (function() { | ||
var compile_entries, configure_content, fetch_content, format_content, format_entry, get_all_content, reconfigure_alt_type_config, set_locals, set_urls; | ||
var asset_view_helper, compile_entries, configure_content, fetch_content, format_content, format_entry, get_all_content, reconfigure_alt_type_config, set_locals, set_urls; | ||
@@ -49,2 +51,3 @@ function RootsContentful(_at_roots) { | ||
} | ||
this.roots.config.locals.asset = asset_view_helper; | ||
} | ||
@@ -225,2 +228,30 @@ | ||
/** | ||
* View helper for accessing the actual url from a Contentful asset | ||
* and appends any query string params | ||
* @param {Object} asset - Asset object returned from Contentful API | ||
* @param {Object} opts - Query string params to append to the URL | ||
* @return {String} - URL string for the asset | ||
*/ | ||
asset_view_helper = function(asset, params) { | ||
var url, _base; | ||
if (asset == null) { | ||
asset = {}; | ||
} | ||
if (asset.fields == null) { | ||
asset.fields = {}; | ||
} | ||
if ((_base = asset.fields).file == null) { | ||
_base.file = {}; | ||
} | ||
url = asset.fields.file.url; | ||
if (params) { | ||
return url + "?" + (querystring.stringify(params)); | ||
} else { | ||
return url; | ||
} | ||
}; | ||
return RootsContentful; | ||
@@ -227,0 +258,0 @@ |
{ | ||
"name": "roots-contentful", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "An extension for using roots with the API-driven Contentful CMS", | ||
@@ -10,11 +10,11 @@ "main": "lib", | ||
"dependencies": { | ||
"lodash": "2.4.x", | ||
"lodash": "3.6.x", | ||
"roots-util": "0.1.x", | ||
"contentful": "0.1.x", | ||
"when": "3.4.x", | ||
"string": "~1.9.x", | ||
"pluralize": "0.0.10" | ||
"contentful": "1.1.x", | ||
"when": "3.7.x", | ||
"string": "3.1.x", | ||
"pluralize": "1.1.x" | ||
}, | ||
"devDependencies": { | ||
"chai": "1.x", | ||
"chai": "2.x", | ||
"chai-as-promised": "4.x", | ||
@@ -21,0 +21,0 @@ "coffee-script": "1.7.x", |
@@ -120,2 +120,12 @@ Roots Contentful | ||
### Asset Image Helper | ||
roots-contentful also provides a convenient view helper called `asset` that allows you to pass in the asset object returned from their API and returns the url. You can also pass in options that will be appended to the image url as a a query string that allows you to specificy size and quality params as documented [here](https://www.contentful.com/developers/documentation/content-delivery-api/javascript/#image-asset-resizing). | ||
```jade | ||
- for post in contentful.posts | ||
img(src!= asset(post.image, {w: 100, h: 100, q: 50})) | ||
``` | ||
### License & Contributing | ||
@@ -122,0 +132,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
36300
41
228
134
+ Addedaxios@0.5.4(transitive)
+ Addedcontentful@1.1.5(transitive)
+ Addedes6-promise@2.3.0(transitive)
+ Addedlodash@3.6.0(transitive)
+ Addedpluralize@1.1.6(transitive)
+ Addedstring@3.1.3(transitive)
+ Addedwhen@3.7.8(transitive)
- Removedbl@0.7.0(transitive)
- Removedbluebird@0.11.6(transitive)
- Removedcontentful@0.1.2(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removedisarray@0.0.1(transitive)
- Removedpluralize@0.0.10(transitive)
- Removedprocess@0.5.2(transitive)
- Removedquestor@1.0.0-alpha.2(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedredefine@0.2.1(transitive)
- Removedstream-browserify@0.1.3(transitive)
- Removedstring@1.9.1(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedunderscore@1.13.7(transitive)
- Removedunderscore-contrib@0.2.2(transitive)
- Removedwhen@3.4.6(transitive)
Updatedcontentful@1.1.x
Updatedlodash@3.6.x
Updatedpluralize@1.1.x
Updatedstring@3.1.x
Updatedwhen@3.7.x