-
Notifications
You must be signed in to change notification settings - Fork 2
/
metalsmith.html
407 lines (326 loc) · 11.8 KB
/
metalsmith.html
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Building Static (Web) Sites w/ Metalsmith (Node.js)</title>
<meta name="generator" content="Slide Show (S9) v2.5.0 on Ruby 2.1.5 (2014-11-13) [i386-mingw32]">
<meta name="author" content="Your Name Here" >
<!-- helper/macro that lets you add (CSS3) gradient using headers
see http://slideshow.rubyforge.org/themes.html
-->
<!-- S6 style sheet links -->
<link rel="stylesheet" href="metalsmith.css" media="projection" id="styleProjection">
<link rel="stylesheet" href="s6/screen.css" media="screen" id="styleScreen">
<link rel="stylesheet" href="s6/print.css" media="print">
<!-- S6 JS -->
<script src="s6/jquery.js"></script>
<script src="s6/jquery.slideshow.js"></script>
<script>
$(document).ready( function() {
Slideshow.init();
} );
</script>
<!-- Better Browser Banner for Microsoft Internet Explorer (IE) -->
<!--[if IE]>
<script src="s6/jquery.microsoft.js"></script>
<![endif]-->
</head>
<body>
<div class="layout">
<div id="header"></div>
<div id="footer">
<h1>Your Footer Here</h1>
<h2>Your Subfooter Here</h2>
</div>
</div>
<div class="presentation">
<div class='slide '>
<!-- === begin markdown block ===
generated by markdown/1.2.0 on Ruby 2.1.5 (2014-11-13) [i386-mingw32]
on 2016-02-25 17:32:17 +0100 with Markdown engine kramdown (1.9.0)
using options {}
-->
<!-- _S9SLIDE_ -->
<h1 id="agenda">Agenda</h1>
<ul>
<li>What’s Metalsmith?</li>
<li>Everything is a Plugin</li>
<li>File / Directory Structure</li>
<li>Real World Showcase - Node.js Project Site</li>
<li>More Plugins</li>
</ul>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="whats-metalsmith">What’s Metalsmith?</h1>
<p>A static site builder in JavaScript (Node.js).</p>
<p><img src="i/staticgen-metalsmith.png" alt="" /></p>
<p>See <a href="http://www.metalsmith.io"><code>metalsmith.io</code></a> »</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="metalsmith---everything-is-a-plugin">Metalsmith - Everything is a Plugin</h1>
<p>Configure file processing build pipeline / chain using plugins</p>
<p>Example - <code>build.js</code>:</p>
<pre><code>Metalsmith(_dirname)
.source( 'src' )
/*******************
add plugins here
******************* /
.destination( 'build' )
.build( function(err) {
if (err) console.log(err);
});
</code></pre>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="metalsmith---everything-is-a-plugin-cont">Metalsmith - Everything is a Plugin (Cont.)</h1>
<p>Example:</p>
<pre><code> .use( metadata({
links: './data/links.json' }))
.use( inPlace({
engine: 'nunjucks',
pattern: '**/*.html' }))
.use( markdown() )
.use( layouts({
engine: 'nunjucks',
directory: './layouts' }))
</code></pre>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="metalsmith---file--directory-structure">Metalsmith - File / Directory Structure</h1>
<pre><code>├── build.js # Metalsmith build script / configuration
├── layouts/
| ├── default.html # master layout template
| ├── page.html # - layout for pages
| └── post.html # - layout for blog posts
└─── src/
├── css/
| └── style.css
├── data/
| └── links.json # datafile (in json)
├── posts/
| ├── 2014-11-11-new-repo-maps.md
| ├── 2014-12-12-new-build-system.md
| └── 2015-08-25-new-season.md
├── about.md # about page (in markdown e.g. md)
└── index.html # front page (in hypertext e.g. html)
</code></pre>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="metalsmith---file--directory-structure----output">Metalsmith - File / Directory Structure - Output</h1>
<p>Use:</p>
<pre><code>$ node build.js
</code></pre>
<p>Resulting in:</p>
<pre><code>└─── build/
├── css/
| └── style.css
├── posts/
| ├── 2014-11-11-new-repo-maps.html
| ├── 2014-12-12-new-build-system.html
| └── 2015-08-25-new-season.html
├── about.html
└── index.html
</code></pre>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="metalsmith---file--directory-structure----output-cont">Metalsmith - File / Directory Structure - Output (Cont.)</h1>
<p><img src="i/staystatic-samplesite.png" alt="" /></p>
<p>(Source: Stay Static Sample Site Showcase - <code>index.html</code>)</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="real-world-showcase----nodejs-project-site">Real World Showcase - Node.js Project Site</h1>
<p><img src="i/showcase-nodejs.png" alt="" /></p>
<p>See <a href="https://nodejs.org"><code>nodejs.org</code></a>
<a href="https://github.com/nodejs/nodejs.org">(Source)</a> »</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="real-world-showcase-1----nodejs-project-site-cont">Real World Showcase #1 - Node.js Project Site (Cont.)</h1>
<p>Source - <a href="https://github.com/nodejs/nodejs.org/blob/master/build.js"><code>build.js</code></a>:</p>
<pre><code>const Metalsmith = require('metalsmith')
const collections = require('metalsmith-collections')
const feed = require('metalsmith-feed')
const layouts = require('metalsmith-layouts')
const markdown = require('metalsmith-markdown')
const prism = require('metalsmith-prism')
const stylus = require('metalsmith-stylus')
const permalinks = require('metalsmith-permalinks')
const pagination = require('metalsmith-yearly-pagination')
...
const metalsmith = Metalsmith(__dirname)
metalsmith
// Sets global metadata imported from the locale's respective site.json.
.metadata({
site: require(siteJSON),
project: source.project,
i18n: i18nJSON(locale)
})
// Sets the build source as the locale folder.
.source(path.join(__dirname, 'locale', locale))
// Defines the blog post/guide collections used to internally group them for
// easier future handling and feed generation.
.use(collections({
blog: {
pattern: 'blog/**/*.md',
sortBy: 'date',
reverse: true,
refer: false
},
blogAnnounce: {
pattern: 'blog/announcements/*.md',
sortBy: 'date',
reverse: true,
refer: false
},
blogReleases: {
pattern: 'blog/release/*.md',
sortBy: 'date',
reverse: true,
refer: false
},
blogVulnerability: {
pattern: 'blog/vulnerability/*.md',
sortBy: 'date',
reverse: true,
refer: false
},
lastWeekly: {
pattern: 'blog/weekly-updates/*.md',
sortBy: 'date',
reverse: true,
refer: false,
limit: 1
},
tscMinutes: {
pattern: 'foundation/tsc/minutes/*.md',
sortBy: 'date',
reverse: true,
refer: false
},
knowledgeBase: {
pattern: 'knowledge/**/*.md',
refer: false
},
guides: {
pattern: 'docs/guides/!(index).md',
refer: false
}
}))
.use(pagination({
path: 'blog/year',
iteratee: (post, idx) => ({
post,
displaySummary: idx < 10
})
}))
.use(markdown(markedOptions))
.use(githubLinks({ locale: locale }))
.use(prism())
// Deletes Stylus partials since they'll be included in the main CSS file
// anyways.
.use(filterStylusPartials())
.use(stylus({
compress: true,
paths: [path.join(__dirname, 'layouts', 'css')],
use: [autoprefixer()]
}))
// Set pretty permalinks, we don't want .html suffixes everywhere.
.use(permalinks({
relative: false
}))
// Generates the feed XML files from their respective collections which were
// defined earlier on.
.use(feed({
collection: 'blog',
destination: 'feed/blog.xml',
title: 'Node.js Blog'
}))
.use(feed({
collection: 'blogAnnounce',
destination: 'feed/announce.xml',
title: 'Node.js Announcements'
}))
.use(feed({
collection: 'blogReleases',
destination: 'feed/releases.xml',
title: 'Node.js Blog: Releases'
}))
.use(feed({
collection: 'blogVulnerability',
destination: 'feed/vulnerability.xml',
title: 'Node.js Blog: Vulnerability Reports'
}))
.use(feed({
collection: 'tscMinutes',
destination: 'feed/tsc-minutes.xml',
title: 'Node.js Technical Steering Committee meetings'
}))
// Finally, this compiles the rest of the layouts present in ./layouts.
// They're language-agnostic, but have to be regenerated for every locale
// anyways.
.use(layouts({
engine: 'handlebars',
pattern: '**/*.html',
partials: 'layouts/partials',
helpers: {
copyright: require('./scripts/helpers/copyright-year.js'),
equals: require('./scripts/helpers/equals.js'),
startswith: require('./scripts/helpers/startswith.js'),
i18n: require('./scripts/helpers/i18n.js'),
changeloglink: require('./scripts/helpers/changeloglink.js'),
strftime: require('./scripts/helpers/strftime.js'),
apidocslink: require('./scripts/helpers/apidocslink.js'),
majorapidocslink: require('./scripts/helpers/majorapidocslink.js'),
summary: require('./scripts/helpers/summary.js')
}
}))
// Pipes the generated files into their respective subdirectory in the build
// directory.
.destination(path.join(__dirname, 'build', locale))
// This actually executes the build and stops the internal timer after
// completion.
metalsmith.build(function (err) {
if (err) { throw err }
console.timeEnd('[metalsmith] build/' + locale + ' finished')
})
}
</code></pre>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="metalsmith---more-plugins">Metalsmith - More Plugins</h1>
<p><strong>metadata</strong> - Load metadata from JSON or YAML files.</p>
<p><strong>inPlace</strong> - In-place templating, render templates in your source files.</p>
<p><strong>markdown</strong> - Convert Markdown files to HTML.</p>
<p><strong>layouts</strong> - Apply layouts to your source files.</p>
<hr />
<p><strong>drafts</strong> - Hide any files marked as drafts.</p>
<p><strong>permalinks</strong> - Apply custom permalinks and rename files to be nested properly for
static sites, basically converting about.html into about/index.html.</p>
<p><strong>collections</strong> - Group files together, like blog posts.
That way you can loop over them to generate an index, or add ‘next’ and ‘previous’
links between them.</p>
<p><strong>feed</strong> - Generate an RSS feed for a collection.</p>
<p><strong>excerpts</strong> - Extract the first paragraph from the beginning of any HTML file.</p>
<p>And Many More</p>
</div>
<div class='slide '>
<!-- _S9SLIDE_ -->
<h1 id="links-links-links">Links, Links, Links</h1>
<p>Interested in Static (Web) Site Builders / Generators?</p>
<p>Follow the <a href="https://twitter.com/statictimes">Static Times News Channel</a>.</p>
<p>or</p>
<p>See the <a href="http://staystatic.github.io">Stay Static Showcase</a>.</p>
<p>Thanks.</p>
<!-- === end markdown block === -->
</div>
</div><!-- presentation -->
</body>
</html>