Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
express-prismic
Advanced tools
Prismic.io support for ExpressJS
This is a set of helpers to use Prismic.io in an Express application. If you're starting from scratch, our NodeJS SDK is a good base.
After including express-prismic
in your package.json
, simply import the prismic object:
var prismic = require('express-prismic').Prismic;
The Prismic object is extended from the Javascript Kit, so any attribute of the official kit, for example Predicates
, is also available in the object exposed by express-prismic.
It needs to be initialized with your configuration:
prismic.init({
apiEndPoint: "https://your-repo-name.prismic.io", // Mandatory
linkResolver: function(doc) { // Mandatory
return false;
},
accessToken: "xxx" // Optional
});
You can then create a Prismic context in your routes if you need to query your repository:
app.route('/').get(function(req, res) {
var p = prismic.withContext(req,res); // This will retrieve the API object asynchronously (using a promise)
p.getByUID('page', 'get-started', function (err, document) {
res.render('index-prismic', {
document: document
});
});
});
Several helper functions are available to query your repository. The most flexible is the query
function:
var p = prismic.withContext(req,res); // This will retrieve the API object asynchronously (using a promise)
p.query(prismic.Predicate.fulltext('document', term), {
page: 2,
pageSize: 10
}, function (err, results) {
[...]
});
You can preview any document including drafts in your production site, securely. All you have to do is:
app.route('/preview').get(prismic.preview);
FAQs
Prismic.io support for Prismic.io
The npm package express-prismic receives a total of 8 weekly downloads. As such, express-prismic popularity was classified as not popular.
We found that express-prismic 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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.