Skip to content

Instantly share code, notes, and snippets.

@ninadhatkar
Last active April 27, 2017 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninadhatkar/60bb71d26ba3704d095202e3e095dd03 to your computer and use it in GitHub Desktop.
Save ninadhatkar/60bb71d26ba3704d095202e3e095dd03 to your computer and use it in GitHub Desktop.
//Sample code of a plugin file to understand the usage of 'req.contentstack.get(key)'
/*!
* myplugin
*/
"use strict";
/*!
* Module dependencies
*/
var contentstack = require('contentstack-express');
module.exports = function Myplugin() {
var options = Myplugin.options;
Myplugin.templateExtends = function(engine) {};
Myplugin.serverExtends = function(app) {
app
.extends()
.use("/about-us", function(req, res, next) {
console.log("OriginalUrl:",req.contentstack.get('originalUrl'));
console.log("URL:",req.contentstack.get('url'));
console.log("ParsedUrl:",req.contentstack.get('parsedUrl'));
console.log("Language:",req.contentstack.get('lang'));
console.log("Content_Type:",req.contentstack.get('content_type'));
console.log("Query:",req.contentstack.get('query'));
console.log("Entry:",req.contentstack.get('entry'));
console.log("Template:",req.contentstack.get('template'));
next()
});
};
Myplugin.beforePublish = function(data, next) {
next();
};
Myplugin.beforeUnpublish = function(data, next) {
next();
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment