Skip to content

Commit fddca2a

Browse files
committed
applied semantic-ui to markdown content
externalized markdown config set markdown's renderer override to use semantic-ui standardized lists in site content content to divs updated grunt to v0.4.5 (fixed a bug with options passing) added marked devDependency dropped a cargo-cult block from docpad.js
1 parent fb27cf7 commit fddca2a

14 files changed

+107
-54
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The site build with [Grunt](http://www.gruntjs.com) and generated using [docpad]
99

1010
## Edit online
1111

12-
1. Use the github web interface to quickly make text edits like updating the [guides](/guides.html) and the [directory](/directory.html). It will create a fork and allows to modify content without leaving your browser.
12+
1. Use the github web interface to quickly make text edits like updating the [guides](/guides.html) and the [directory](/directory.html). It will create a fork and allows to modify content without leaving your browser.
1313

1414
1. The content is saved as markdown and located in `./src/documents`.
1515

docpad.js

+1-32
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
/* jshint -W014 */
22

3-
4-
var hljs;
5-
function highlightCode(code, lang) {
6-
if (!hljs) {
7-
hljs = require('highlight.js');
8-
hljs.configure({tabReplace: ' '}); // 4 spaces
9-
hljs.registerLanguage('typescript', require('./lib/highlight/typescript'));
10-
}
11-
if (lang) {
12-
return hljs.highlight(lang, code).value;
13-
}
14-
return hljs.highlightAuto(code).value;
15-
}
16-
173
var docpadConfig = {
184
templateData: {
195
site: {
@@ -119,27 +105,10 @@ var docpadConfig = {
119105
},
120106
plugins: {
121107
marked: {
122-
markedOptions: {
123-
gfm: true,
124-
highlight: highlightCode
125-
}
108+
markedOptions: require('./lib/marked')
126109
}
127110
},
128111
events: {
129-
serverExtend: function(opts) {
130-
var server = opts.server;
131-
var docpad = this.docpad;
132-
var latestConfig = docpad.getConfig();
133-
var oldUrls = latestConfig.templateData.site.oldUrls || [];
134-
var newUrl = latestConfig.templateData.site.url;
135-
return server.use(function(req, res, next) {
136-
if (oldUrls.indexOf(req.headers.host) >= 0) {
137-
return res.redirect(newUrl + req.url, 301);
138-
} else {
139-
return next();
140-
}
141-
});
142-
}
143112
}
144113
};
145114

lib/marked.js

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
var marked = require('marked');
2+
3+
var hljs;
4+
function highlightCode(code, lang) {
5+
if (!hljs) {
6+
hljs = require('highlight.js');
7+
hljs.configure({tabReplace: ' '}); // 4 spaces
8+
hljs.registerLanguage('typescript', require('./highlight/typescript'));
9+
}
10+
if (lang) {
11+
return hljs.highlight(lang, code).value;
12+
}
13+
return hljs.highlightAuto(code).value;
14+
}
15+
16+
var renderer = new marked.Renderer();
17+
18+
renderer.code = function(code, lang, escaped) {
19+
if (this.options.highlight) {
20+
var out = this.options.highlight(code, lang);
21+
if (out != null && out !== code) {
22+
escaped = true;
23+
code = out;
24+
}
25+
}
26+
27+
if (!lang) {
28+
return '<pre><code>'
29+
+ (escaped ? code : escape(code, true))
30+
+ '\n</code></pre>';
31+
}
32+
33+
return '<pre><code class="'
34+
+ this.options.langPrefix
35+
+ escape(lang, true)
36+
+ '">'
37+
+ (escaped ? code : escape(code, true))
38+
+ '\n</code></pre>\n';
39+
};
40+
41+
renderer.heading = function(text, level, raw) {
42+
return '<h'
43+
+ level
44+
+ ' id="'
45+
+ this.options.headerPrefix
46+
+ raw.toLowerCase().replace(/[^\w]+/g, '-')
47+
+ '" class="ui header">'
48+
+ text
49+
+ '</h'
50+
+ level
51+
+ '>\n';
52+
};
53+
54+
renderer.hr = function() {
55+
return '<div class="ui divider"></div>\n';
56+
};
57+
58+
renderer.list = function(body, ordered) {
59+
if (ordered) {
60+
return '<div class="ui ordered list">' + body + '</div>';
61+
}
62+
return '<div class="ui list">' + body + '</div>';
63+
};
64+
65+
renderer.listitem = function(text) {
66+
return '<div class="ui item">' + text + '</div>\n';
67+
};
68+
69+
renderer.table = function(header, body) {
70+
return '<table class="ui table">\n'
71+
+ '<thead>\n'
72+
+ header
73+
+ '</thead>\n'
74+
+ '<tbody>\n'
75+
+ body
76+
+ '</tbody>\n'
77+
+ '</table>\n';
78+
};
79+
80+
module.exports = {
81+
gfm: true,
82+
renderer: renderer,
83+
highlight: highlightCode
84+
};

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@
3131
"scripts": {
3232
"test": "grunt test"
3333
},
34-
"dependencies": {
35-
},
34+
"dependencies": {},
3635
"devDependencies": {
3736
"docpad": "~6.64.0",
3837
"docpad-plugin-eco": "~2.0.3",
3938
"docpad-plugin-marked": "~2.2.0",
4039
"docpad-plugin-partials": "~2.9.0",
4140
"docpad-plugin-less": "~2.4.1",
4241
"docpad-plugin-livereload": "~2.6.0",
43-
"grunt": "^0.4.4",
42+
"grunt": "^0.4.5",
4443
"grunt-cli": "^0.1.13",
4544
"grunt-gh-pages": "0.9.1",
4645
"grunt-contrib-clean": "^0.5.0",
4746
"grunt-contrib-jshint": "^0.10.0",
4847
"grunt-contrib-copy": "^0.5.0",
4948
"jshint-path-reporter": "^0.1.3",
50-
"highlight.js": "^8.0.0"
49+
"highlight.js": "^8.0.0",
50+
"marked": "^0.3.2"
5151
},
5252
"main": "node_modules/docpad/bin/docpad-server"
5353
}

src/documents/directory.html.eco

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ title: 'TypeScript Directory'
88
</div>
99

1010
<div class="ui row">
11-
<ul class="ui list">
11+
<div class="ui list">
1212
<% for item in @getCollection('directory').sortArray(date: -1): %>
1313
<a class="item" href="<%= item.url %>">
1414
<%- item.title or item.name %></a>
1515
<%- item.description %>
1616
<% end %>
17-
</ul>
17+
</div>
1818
</div>
1919

2020
<%- @partial('contribute') %>

src/documents/directory/tools.html.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ title: 'Tools & Editors'
4242
* [CATS](https://github.com/jbaron/cats) Code Assistant for TypeScript
4343
* [typescript-vim](https://github.com/leafgarland/typescript-vim)
4444
* [sublime-typescript](https://github.com/raph-amiard/sublime-typescript)
45-
* [typescript-tools](https://github.com/clausreinke/typescript-tools) Command line access to TypeScript language services (types, completion, jump to definition, errors); Vim plugin
45+
* [typescript-tools](https://github.com/clausreinke/typescript-tools) CLI access to TypeScript language services; Vim plugin

src/documents/guides.html.eco

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ title: 'Guides'
88
</div>
99

1010
<div class="ui row">
11-
<ul class="ui list">
11+
<div class="ui list">
1212
<% for item in @getCollection('guides').sortArray(date: -1): %>
1313
<a class="item" href="<%= item.url %>">
1414
<%- item.title or item.name %></a>
1515
<%- item.description %>
1616
<% end %>
17-
</ul>
17+
</div>
1818
</div>
1919

2020
<%- @partial('contribute') %>

src/documents/pages.html.eco

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ title: 'Pages'
88
</div>
99

1010
<div class="ui row">
11-
<ul class="ui list">
11+
<div class="ui list">
1212
<% for item in @getCollection('pages').sortArray(date: -1): %>
1313
<a class="item" href="<%= item.url %>">
1414
<%- item.title or item.name %></a>
1515
<%- item.description %>
1616
<% end %>
17-
</ul>
17+
</div>
1818
</div>
1919

2020
<%- @partial('contribute') %>

src/documents/pages/badges.html.md.eco

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: 'Badges'
77
JavaScript libraries that have TypeScript definitions on DefinitelyTyped can show their support by adding a badge to their README.
88

99
<div class="ui message">
10-
**Experimental** Currently we offer a simple badge that links to [definitelytyped.org](http://definitelytyped.org). <br><br/>We are working on a CDN with `https;//` support, and a feature to link to a definition-specific information page.
10+
**Experimental** Currently we offer a simple badge that links to [definitelytyped.org](http://definitelytyped.org). <br><br/>We are working on a CDN with https support, and a feature to link to a definition-specific information page.
1111
</div>
1212

1313

src/layouts/directory.html.eco

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ layout: content
1212
<%- @partial('contribute') %>
1313
</div>
1414

15-
<ul class="ui list">
15+
<div class="ui list">
1616
<% for item in @getCollection('directory').sortArray(date: -1): %>
1717
<a class="item" href="<%= item.url %>"><%- item.title or item.name %></a>
1818
<%- item.description %>
1919
<% end %>
20-
</ul>
20+
</div>

src/layouts/guide.html.eco

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ layout: content
1212
<%- @partial('contribute') %>
1313
</div>
1414

15-
<ul class="ui list">
15+
<div class="ui list">
1616
<% for item in @getCollection('guides').sortArray(date: -1): %>
1717
<a class="item" href="<%= item.url %>"><%- item.title or item.name %></a>
1818
<%- item.description %>
1919
<% end %>
20-
</ul>
20+
</div>

src/layouts/page.html.eco

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ layout: content
1010
<%- @content %>
1111
</div>
1212

13-
<ul class="ui list">
13+
<div class="ui list">
1414
<% for item in @getCollection('pages').sortArray(date: -1): %>
1515
<a class="item" href="<%= item.url %>"><%- item.title or item.name %></a>
1616
<%- item.description %>
1717
<% end %>
18-
</ul>
18+
</div>

src/partials/contribute.html.eco

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<div class="ui small segment">
2-
Contribute to the site via <a href="/pages/website-contributions.html">website contribution guide</a>.
2+
Contribute to the site via the <a href="/pages/website-contributions.html">contribution guide</a>.
33
</div>

src/partials/guides-menu.html.eco

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<h2 class="header">
22
See more
33
</h2>
4-
<ul class="ui list">
4+
<div class="ui list">
55
<% for item in @getCollection('guides').sortArray(date: -1): %>
66
<a class="item" href="<%= item.url %>"><i class="right triangle icon"></i> <%- item.title or item.name %></a>
77
<%- item.description %>
88
<% end %>
9-
</ul>
9+
</div>

0 commit comments

Comments
 (0)