http://stackoverflow.com/q/14327676/130638
- Install express into your project
npm install --save express
http://stackoverflow.com/q/14327676/130638
npm install --save express
# Import | |
express = require('express') | |
# Create our auth middleware | |
authMiddleware = express.basicAuth (user, pass) -> | |
return user is 'super' and pass is 'secret' | |
# Configure DocPad | |
docpadConfig = | |
serverExtend: (opts) -> | |
# Prepare | |
docpad = @ | |
# Define our own custom middleware to handle protected pages | |
opts.serverExpress.use (req,res,next) => | |
# Prepare | |
cleanUrl = req.url.replace(/\?.*/,'') | |
file = docpad.getFileByUrl(req.url) or docpad.getFileByUrl(cleanUrl) | |
# Continue with the next middleware if the file doesn't exist or isn't protected | |
return next() unless file?.get('protected') | |
# The file is protected so lets forward the request onto our auth middleware | |
return authMiddleware(req,res,next) | |
# Export | |
module.exports = docpadConfig |
title: "My protected document"
protected: true
Only make me available if the user has authetnicated themselve
You most likely meant
docpad = @docpad
instead of
docpad = @