diff --git a/.gitignore b/.gitignore index c07614a..c5e43c8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ node_modules/ output/* !output/menu.html !output/index.html - +.DS_Store diff --git a/lib/pipeline.js b/lib/pipeline.js index 53ec3af..ff6b662 100644 --- a/lib/pipeline.js +++ b/lib/pipeline.js @@ -7,6 +7,11 @@ var fs = require('fs'), convertMd = require('./convert-md'); module.exports = function(argv) { + if (!argv.meta) { + // load the metadata file if it exists + argv.meta = fs.existsSync(argv.input + '/meta.json') ? require(argv.input + '/meta.json') : {}; + } + return pi.pipeline([ md.parseHeader(), md.parseMd(), @@ -25,15 +30,12 @@ module.exports = function(argv) { setOutputPath({ input: argv.input, output: argv.output, - isSingleFile: argv.isSingleFile + isSingleFile: argv.isSingleFile, + 'asset-path': argv['asset-path'] }), // merge metadata now that relative is set - mergeMeta( - // load the metadata file if it exists - fs.existsSync(argv.input + '/meta.json') ? - require(argv.input + '/meta.json') : {} - ), + mergeMeta(argv.meta), // apply handlebars templates applyTemplate({ diff --git a/lib/set-output-path.js b/lib/set-output-path.js index dfdcd14..1488cd2 100644 --- a/lib/set-output-path.js +++ b/lib/set-output-path.js @@ -21,7 +21,7 @@ module.exports = function(opts) { // determine the relative path to ./output/assets // -- since files can be in subdirs like: sub/sub/dir/index.html - item.assetsRelative = path.relative(outputDir, opts.output + '/assets'); + item.assetsRelative = path.relative(outputDir, opts['asset-path'] || opts.output + '/assets'); return item; }); diff --git a/readme.md b/readme.md index e9dcdbf..0e59dae 100644 --- a/readme.md +++ b/readme.md @@ -339,6 +339,9 @@ If any markdown file in `./input/foo/` defines a metadata value called `repoUrl` - `path` (an absolute path to the input file name), - `stat` (the fs.stat object associated with the input file), - `contents` (a string with the content of the input file). +- Since `v3.1.3`, the `pipeline` function supports a couple of arguments that are not exposed on the CLI (in addition to all the CLI args): + - `meta`: a hash of JSON (the contents of a meta.json file if you prefer to set that explicitly) + - `asset-path`: a full path to the `/assets` folder, defaults to `${output}/assets`. The writable stream returns objects with the same properties, plus any metadata. The pipeline updates `path` to be the output path that generate-md would write the file to, and updates `contents` to be a string of HTML. diff --git a/test/integration.test.js b/test/integration.test.js index 100c256..4513b11 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -177,7 +177,7 @@ describe('integration tests', function() { setOutputPath({ input: '/fake/input', output: '/fake/output', - assetDir: '/fake/output/assets/' + 'asset-path': '/fake/output/assets/' }), applyTemplate(opts), @@ -213,8 +213,8 @@ describe('integration tests', function() { }, { template: 'a{{> toc}}b' }, function(html) { assert.equal(html, [ 'a
', 'b' ].join('\n')); diff --git a/todo.md b/todo.md index cf3d823..96f22f3 100644 --- a/todo.md +++ b/todo.md @@ -36,3 +36,16 @@ - quiz - equations - exercises +- sidebar menu component + - responsive (e.g. top-level hamburger icon on mobile) + - toggleable (e.g. tablet) + - https://dribbble.com/shots/1830513-Tumblr-Free-PSD-Template + - https://dribbble.com/shots/1590417-Portfolio-Review-Page +- scrollable, expanding TOC + - sticky on side + - scrollable on overflow + - expands to match specific targets + - has buttons to expand specific sections +- full site TOC views / helpers ?? +- better preview system (e.g. theme switcher, hosted online) +