Skip to content

Commit

Permalink
fixes #8: default home document will fallback to REAME.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Oct 16, 2013
1 parent cdc3484 commit c0764f2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
2 changes: 0 additions & 2 deletions README.md
Expand Up @@ -6,8 +6,6 @@

Create your document site with only one command.

`document` also contains utility methods to parse the document tree.

# Life gets easier

To create your document site, just:
Expand Down
24 changes: 15 additions & 9 deletions lib/config.js
Expand Up @@ -168,7 +168,6 @@ config.get_config = function (cli_args, callback) {
'doc'
);


config.read_config_json(doc, function (err, cfg) {
if ( err ) {
return callback(err);
Expand All @@ -186,19 +185,26 @@ config.get_config = function (cli_args, callback) {

var theme = cli_args.theme || node_path.join(__dirname, '..', 'theme');

var readme = node_path.join(cwd, 'README.md');
var sys = {
cwd: cwd,
doc: doc,

// hard coded
theme: theme,
public_root: node_path.join(theme, 'public')
};

if ( fs.isFile(readme) ) {
sys.readme = readme;
}

callback(null, {
// user configurations that is mainly used by templates
user: result,

// configurations relevant to the system, which are critical and should not be exposed
sys: {
cwd: cwd,
doc: doc,

// hard coded
theme: theme,
public_root: node_path.join(theme, 'public')
}
sys: sys
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion lib/dao.js
Expand Up @@ -32,7 +32,7 @@ dao.tree = function (options, callback) {

var ltree = parser.language_tree(raw_tree, user.languages);

parser.create_data(ltree, function (err, data) {
parser.create_data(ltree, sys, function (err, data) {
if ( err ) {
return dao._complete(err);
}
Expand Down
8 changes: 7 additions & 1 deletion lib/parser.js
Expand Up @@ -217,7 +217,7 @@ parser.sort_pages = function (pages) {


// create a cache
parser.create_data = function (language_tree, callback) {
parser.create_data = function (language_tree, sys, callback) {
var counter = Object.keys(language_tree).length;
var error;
var nodes = [];
Expand Down Expand Up @@ -261,6 +261,12 @@ parser.create_data = function (language_tree, callback) {
};

lang.each(language_tree, function (l, language) {
var tree = l.tree;

if ( !tree.path ) {
tree.path = sys.readme;
}

parser.walk(l.tree, iterator, function (err) {
if ( err ) {
error = err;
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "document",
"version": "0.2.3",
"version": "0.3.1",
"description": "Create your document site with just one command.",
"// main": "index.js",
"bin": {
Expand Down

0 comments on commit c0764f2

Please sign in to comment.