Permalink
Browse files

Add additional options to better support programmatic rendering

  • Loading branch information...
1 parent 65da752 commit 3937d4d87606519782a8bfdb9e4d44c0581baa67 @mixu committed Oct 23, 2015
Showing with 29 additions and 11 deletions.
  1. +1 −1 .gitignore
  2. +8 −6 lib/pipeline.js
  3. +1 −1 lib/set-output-path.js
  4. +3 −0 readme.md
  5. +3 −3 test/integration.test.js
  6. +13 −0 todo.md
View
@@ -2,4 +2,4 @@ node_modules/
output/*
!output/menu.html
!output/index.html
-
+.DS_Store
View
@@ -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({
@@ -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;
});
View
@@ -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.
@@ -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<ul class="nav nav-list">',
- ' <li><a href="#foo">foo</a></li>',
- ' <li><a href="#bar">bar</a></li>',
+ ' <li class="sidebar-header-1"><a href="#foo">foo</a></li>',
+ ' <li class="sidebar-header-2"><a href="#bar">bar</a></li>',
'</ul>',
'b'
].join('\n'));
View
@@ -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)
+

0 comments on commit 3937d4d

Please sign in to comment.