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

roots-contentful

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

roots-contentful - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

test/fixtures/image_view_helper/app.coffee

35

lib/index.js
// 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 @@

14

package.json
{
"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

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