Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
roots-contentful
Advanced tools
An extension for using roots with the Contentful CMS API.
Note: This project is in early development, and versioning is a little different. Read this for more details.
We love static sites. They're fast, resilient, simple, and cheap.
However, managing and updating content on a static site is a pain. This extension allows you to load data from Contentful's API into your roots project for use in your view templates during compilation. Non-developers get an easy way to publish and manage content, while developers can still build static sites in a sane way.
npm install roots-contentful --save
app.coffee
file to include the extension, as suchcontentful = require 'roots-contentful'
# ...
module.exports =
extensions: [
contentful({
access_token: 'YOUR_ACCESS_TOKEN'
space_id: 'xxxxxx'
content_types: [
{
id: 'xxxxxx',
name: 'posts',
template: 'views/_post.jade',
filters: {
'fields.environment[in]': ['staging', 'production']
},
path: (e) -> "blogging/#{e.category}/#{slugify(e.title)}"
},
{
id: 'xxxxxx'
}
]
})
]
# ...
A contentful
view helper object will be passed into every view containing your content. Each content type will be set as a property on contentful
using the name
option in your app.coffee
configuration. For example with the app.coffee
file above, you can access the blog posts like this:
h1 Hello World
ul
- for post in contentful.posts
li
h2= post.title
p= markdown(post.body)
Note: This feature is currently not implemented, but is planned for a future release.
If a template
option is defined for a Content Type in app.coffee
, roots will compile a single page view for each entry in that Content Type collection. The entry will also have a _url
key that returns the path to the single page view (so you can create links on an index page for example).
Contentful's documentation shows the API response when fetching an entry. Your content fields are nested in a fields
key. As a convenience, the entry object roots-contentful makes available in your views will have the fields
key's value set one level higher on the object. System metadata remains accessible on the sys
key and roots-contentful will raise an error if you have a field named sys
. Inside your views, the entry object will have this structure:
{
"title": "Wow. Such title. Much viral",
"author": "The Doge of Venice"
# ... the rest of the fields
"sys": {
"type": "Entry",
"id": "cat"
# ...
}
}
Required. Your Contentful Delivery access token (API key).
Required. The space ID containing the content you wish to retrieve.
An array of objects specifying from which Content Types you wish to fetch entries.
content_type
Each object in the content_types array can have the following properties:
Required. The Content Type's ID on Contentful.
Optional. This is the name of the key the entries will be attached to on the contentful
object in your views. Defaults to a pluralized, underscored representation of the Content Type name (e.g. 'Blog Post' => contentful.blogPosts
)
Optional. Path relative to the roots project of a template for a single entry view. Each entry in the Content Type will be passed into the template in an entry
variable. If not given, the Content Type will not be compiled into single entry views and will only be attached to the contentful
view helper object.
Optional. Takes an object with different filter criteria, see examples of how to structure the object in Contentful's docs.
Optional. Provide a function that returns a string of the relative path to the output file for a given entry without the extension. First argument passed into the function is the entry. Default is <name>/<slug>
where slug
is the slugified output of the entry's displayField
(a property of the Content Type), and name
is the provided name
option above or the default value. This option is ignored if no template
is given.
FAQs
An extension for using roots with the API-driven Contentful CMS
The npm package roots-contentful receives a total of 24 weekly downloads. As such, roots-contentful popularity was classified as not popular.
We found that roots-contentful demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.