-
Notifications
You must be signed in to change notification settings - Fork 3
/
docpad.coffee
125 lines (101 loc) · 3.24 KB
/
docpad.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# DocPad Configuration File
# http://docpad.org/docs/config
cheerio = require('cheerio')
url = require('url')
path = require('path')
# Define the DocPad Configuration
docpadConfig = {
srcPath: ''
ignorePaths: [path.join(process.cwd(), 'out')]
templateData:
# Specify some site properties
site:
# The production url of our website
url: "http://blog.pencilcode.net"
# The default title of our website
title: "Pencil Code Blog"
# The website author's name
author: "Pencil Code Foundation"
# The website author's email
email: "[email protected]"
# cache-busting timestamp
timestamp: new Date().getTime()
# -----------------------------
# Helper Functions
# Get the prepared site/document title
# Often we would like to specify particular formatting to our page's title
# we can apply that formatting here
getPreparedTitle: ->
# if we have a document title, then we should use that and suffix the site's title onto it
if @document.title
"#{@document.title} - #{@site.title}"
# if our document does not have it's own title, then we should just use the site's title
else
@site.title
getPageUrlWithHostname: ->
"#{@site.url}#{@document.url}"
getIdForDocument: (document) ->
hostname = url.parse(@site.url).hostname
date = document.date.toISOString().split('T')[0]
path = document.url
"tag:#{hostname},#{date},#{path}"
fixLinks: (content) ->
if not content? then return ''
baseUrl = @site.url
regex = /^(http|https|ftp|mailto):/
$ = cheerio.load(content)
$('img').each ->
$img = $(@)
src = $img.attr('src')
$img.attr('src', baseUrl + src) unless regex.test(src)
$('a').each ->
$a = $(@)
href = $a.attr('href')
$a.attr('href', baseUrl + href) unless regex.test(href)
$.html()
moment: require('moment')
# Discus.com settings
disqusShortName: 'pencilcode'
# Google+ settings
# googlePlusId: '?????'
getTagUrl: (tag) ->
slug = tag.toLowerCase().replace(/[^a-z0-9]/g, '-').replace(/-+/g, '-').replace(/^-|-$/g, '')
"/tags/#{slug}/"
collections:
posts: ->
@getCollection('documents').findAllLive({relativeDirPath: 'posts'}, [date: -1])
cleanurls: ->
@getCollection('html').findAllLive(skipCleanUrls: $ne: true)
environments:
development:
collections:
posts: ->
@getCollection('documents').findAllLive({relativeDirPath: {'$in' : ['posts', 'drafts']}}, [relativeDirPath: 1, date: -1])
regenerateDelay: 1000
watchOptions:
interval: 2007
catchupDelay: 2000
preferredMethods: ['watchFile','watch']
plugins:
tags:
findCollectionName: 'posts'
extension: '.html'
injectDocumentHelper: (document) ->
document.setMeta(
layout: 'tags'
)
dateurls:
cleanurl: true
trailingSlashes: true
keepOriginalUrls: false
collectionName: 'posts'
dateIncludesTime: true
paged:
cleanurl: true
startingPageNumber: 2
cleanurls:
trailingSlashes: true
collectionName: 'cleanurls'
}
# Export the DocPad Configuration
module.exports = docpadConfig