
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
contentful-static
Advanced tools
A CLI tool to generate a site from templates + data from a contentful space
To build a site from a space using the templates in templatesFolder
contentful-static -a yourAccessToken yourSpaceId templatesFolder/ dest/
Each entry in your contentful data is matched against a template by checking it's contentType
name.
Availiable in the template context are
Name | |
---|---|
entry | The entry for this template |
content | The entire contentful data object. |
entries | All entries |
includes | HTML data for all entries already rendered. Key is id. |
include(entry) | A function (shorthand for direct usage of include). Takes either a list of entries or an entry and returns it's html |
debug(obj) | Print debug for an object |
As a default contentful-static
uses the template language nunjucks.
But since it uses consolidate in theory any other
templating language can be used.
npm install -g contentful-static
var contentfulStatic = require('contentful-static');
contentfulStatic.config({
// Path to templates.
templates: 'templates'
// Your Contentful space ID
space: 'my12space34id',
// Contentful Access Token
accessToken: '5fdae8a3myacc3sst0ken573962'
});
// With promise
contentfulStatic.sync().then(function(json) {
console.log('contentful-static: data stored successfully!', json);
}, function (err) {
console.log('contentful-static: data could not be fetched');
});
// With callback
contentfulStatic.sync(function(err, json) {
if(err) {
console.log('contentful-static: data could not be fetched');
return false;
}
console.log('contentful-static: data fetched successfully!', json);
});
// With promise
contentfulStatic.render(json).then(function(htmls) {
// Rendered data is an object where key is entry sys id and value is its HTML
console.log(htmls);
}, function (err) {
console.log('Could not render templates');
});
// With callback
contentfulStatic.render(json, function(err, htmls) {
// Handle callback
});
FAQs
Save data from a Contentful space to a local JSON file
The npm package contentful-static receives a total of 0 weekly downloads. As such, contentful-static popularity was classified as not popular.
We found that contentful-static demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.