Define a Custom Publishing Strategy

thisgeek edited this page Oct 13, 2012 · 2 revisions

Currently, you can publish a generated site to Amazon S3 or to any other remote server that supports SFTP. If those doesn't fit your needs, you can easily define a custom publishing strategy.

All you need to do is to write a node module, that implements the publish method defined below:

	publish: function(config, last_published_date, callback) {
		// implement your publishing logic here

Punch calls the publish function with the configuration options defined for the site, last published date (if available) and a callback. You have to invoke the callback to notify Punch when the publishing process complete.

How to use a custom publishing strategy

To use a custom publishing strategy in a project, you have to first define it as a plugin in project's configuration (config.json).

		"publishers": {
			"custom_strategy": "customer_strategy_path" 

Then, set it as the publishing strategy.

"publish": {
	"strategy": "custom_strategy"
	"options": {