Last active
April 27, 2017 13:34
-
-
Save ninadhatkar/60bb71d26ba3704d095202e3e095dd03 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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