Commit 9a3c2d4b authored by Doug Webb's avatar Doug Webb

converted slides to templated markdown

parent ecc93f58

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -15,14 +15,21 @@ const collections = require('metalsmith-collections')
const drafts = require('metalsmith-drafts')
const wordcount = require('metalsmith-word-count')
const permalinks = require('metalsmith-permalinks')
const copy = require('metalsmith-copy')
const chalk = require('chalk')
// This guy suggests only using `const` when the identifier won't be reassigned, `let` if it can be and to not use `var` at all. https://medium.com/javascript-scene/javascript-es6-var-let-or-const-ba58b8dcde75
// SETUP
Metalsmith(__dirname) // __dirname defined by node.js:
.source('./src') // specify source directory
.destination('./public') // specify destination directory
.use(drafts()) // omit drafts (YFM `draft: true`) from process
//.use(msSymlink({ // create symlink to `assets` (instead of copying)
//paths: [
//{
......@@ -32,11 +39,20 @@ Metalsmith(__dirname) // __dirname defined by node.js:
//]
//}))
// PROCESS SLIDES
.use(copy({ // rename the extension of slides from .md to .html
pattern: 'slides/*.md',
extension: '.html',
move: true
}))
// PROCESS POSTS
.use(inplace({ // transpile files to .html based on RTL file extenstions
pattern: "posts/*" // transpile files in `posts` (.md) into .html
}))
.use(collections({ // create collection metadata
posts: { // add `collection: [ 'posts' ]` ...
pattern: 'posts/*', // to files in `posts` ...
......@@ -44,6 +60,7 @@ Metalsmith(__dirname) // __dirname defined by node.js:
reverse: true // reverse date order
}
}))
.use(dateFormatter({ // format date-time using 'moment' date formats: http://momentjs.com/
dates: [
{
......@@ -56,7 +73,9 @@ Metalsmith(__dirname) // __dirname defined by node.js:
}
]
}))
.use(wordcount()) // REQUIRES .html! counts words, adds `wordCount` and `readingTime` metadata
.use(permalinks({ // REQUIRES .html! CAUTION don't break URLs! Prettifies URLs by 1. name.html → name/index.html 2. path: name.html → path: name
linksets: [
{
......@@ -68,10 +87,14 @@ Metalsmith(__dirname) // __dirname defined by node.js:
// PROCESS REST
.use(inplace()) // in-place transpiling of remaining .html files (n.b. all `posts` meta-data now available!)
.use(inplace({
//pattern: ["*", "!slides/*"]
})) // in-place transpiling of remaining .html files (n.b. all `posts` meta-data now available!)
.use(layouts({ // injects content + metadata into template specified by a files YFM `layout:`
suppressNoFilesError: true // BAD! Suppresses errors when no layout found. This is lazy, fix it: https://www.npmjs.com/package/metalsmith-layouts
}))
.use(assets({ // copy assets (note: plugin is deprecated, but working)
source: './assets', // from `$SOURCE/assets`
destination: './assets' // to `$DESTINATION/assets`
......@@ -80,7 +103,9 @@ Metalsmith(__dirname) // __dirname defined by node.js:
// BUILD
.clean(true)
.use(debug())
.build((err) => { // build process
if (err) { // error handling is required
throw err
......
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ title }}</title>
<link rel="shortcut icon" type="image/png" href="/assets/img/icons/favicon-256.png">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
p, li {
line-height: 1.4;
}
</style>
</head>
<body>
<!-- break in following nesting alignment necessary to prevent indentation from obstructing initial slide class :.( -->
<textarea id="source">
{% block body %}
{{ contents | safe }}
{% endblock %}
</textarea>
<script src="/assets/js/remark-latest.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS_HTML" type="text/javascript"></script>
<script type="text/javascript">
var slideshow = remark.create();
// Setup MathJax
MathJax.Hub.Config({
tex2jax: {
skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
}
});
MathJax.Hub.Configured();
</script>
</body>
</html>
The MIT License (MIT)
Copyright (c) 2014 - 2017 Matt Widmann
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# metalsmith-copy
This is a plugin for [Metalsmith][] that copies files matching a `pattern`
based on either a `transform` function or a `directory` and `extension`. Think
of metalsmith-copy as a file converter plugin like metalsmith-markdown, but it
doesn't make any changes to the content and name changes are programmatically
specified in its options.
[metalsmith]: http://metalsmith.io
## Usage
If using the CLI for Metalsmith, metalsmith-copy can be used like any other
plugin by including it in `metalsmith.json`. For example:
```json
{
"plugins": {
"metalsmith-copy": {
"pattern": "*.md",
"directory": "markdown-files"
}
}
}
```
Note that the `transform` option cannot be used, as JSON doesn't serialize
JavaScript functions.
For Metalscript's JavaScript API, metalsmith-copy can be used like any other
plugin, by attaching it to the function invocation chain on the Metalscript
object. For example:
```js
var copy = require('metalsmith-copy');
require('metalsmith')(__dirname)
.use(copy({
pattern: '*.md',
transform: function (file) {
return file + '.bak';
}
}))
.build();
```
## Options
metalsmith-copy requires a `pattern` option as well as at least one of the
transformation options: `extension`, `directory`, or `transform`.
- `pattern` is a globbing pattern that specifies which files to copy.
- `extension` is an extension (starting with `.`) that replaces the file's
current last extension.
- `directory` is a directory relative to the build directory for the new file
to be copied.
- `transform` supercedes both `extension` and `directory` and is a function
which takes one argument (the path to the file being copied) and returns a
new path for the file to be copied to.
- `move` is boolean value indicating files should be *moved* instead of copied.
- `force` is a boolean value that will force overwriting destination files. By
default, this is false and overwrites will generate errors.
- `ignore` is a globbing pattern that ignores files, overriding a match with
`pattern`.
## Use Cases
If you're running a blog, perhaps you want to mimic John Gruber's articles,
where he provides both an HTML version of his article and a Markdown version
(ending in `.text`). To set this up with metalsmith-copy, provide the