-
Notifications
You must be signed in to change notification settings - Fork 26
/
docpad.coffee
103 lines (81 loc) · 2.48 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
# DocPad Configuration File
# http://docpad.org/docs/config
cheerio = require('cheerio')
url = require('url')
# Define the DocPad Configuration
docpadConfig = {
pluginsPaths: [
'node_modules'
'plugins'
]
templateData:
# Specify some site properties
site:
# The production url of our website
url: "http://msdevshow.com"
# The default title of our website
title: "MS Dev Show Podcast"
# The website author's name
author: "MS Dev Show"
# The website author's email
email: "jason@ytechie.com"
# -----------------------------
# 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}"
getOldUrl: (newUrl) ->
newUrl.substr(0,newUrl.length-1) + '.html'
fixLinks: (content, baseUrlOverride) ->
baseUrl = @site.url
if baseUrlOverride
baseUrl = baseUrlOverride
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')
getJavascriptEncodedTitle: (title) ->
title.replace("'", "\\'")
# Discus.com settings
disqusShortName: 'msdevshow'
# Google+ settings
#googlePlusId: '105512648454315380048'
# RSS Feed
rssFeedUrl: 'https://static.msdevshow.com/episodes/rss.xml'
collections:
posts: ->
@getCollection("html").findAllLive({layout: 'post', ignored: false}, [{date: -1}])
guests: ->
@getCollection("html").findAllLive({layout: 'post', ignored: false, guest: {$exists: true}}, [{date: -1}])
plugins:
cleanurls:
trailingSlashes: true
nodesass:
outputStyle: 'compressed'
bourbon: true
neat: true
}
# Export the DocPad Configuration
module.exports = docpadConfig