Skip to content

Commit

Permalink
fixes #9: fix the situation if a document has no h1 title
Browse files Browse the repository at this point in the history
  • Loading branch information
kaelzhang committed Oct 17, 2013
1 parent 0991866 commit b5fae99
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 33 deletions.
9 changes: 6 additions & 3 deletions lib/parser.js
Expand Up @@ -237,12 +237,11 @@ parser.create_data = function (language_tree, sys, callback) {

if ( html ) {
node.html = html;
// There might be no title inside the html
title = parser.get_title(html);
} else {
title = node.name;
}

parser._generate_url(node, title);
parser._generate_url(node, title || node.name);

var pages = node.pages;

Expand Down Expand Up @@ -318,6 +317,10 @@ parser._generate_url = function (node, name) {
node.url = '';

} else {
if ( !name ) {
console.log(node);
}

var cooked = parser.cook_name(name);
node.display_name = cooked.display_name;
node.uri_name = cooked.uri_name;
Expand Down
4 changes: 2 additions & 2 deletions lib/tools.js
Expand Up @@ -31,8 +31,8 @@ tools.nav = function (tree, current_doc, config) {
var is_folder = node.type === 'folder';

if ( is_folder ) {
var href = node.url && node.html && (config.site_root + node.url);
html += '<a href="' + (href || '#') + '" class="J_nav J_has-content folder">' + node.display_name + '</a>';
var content_link = node.url && node.html && (config.site_root + node.url);
html += '<a href="' + (content_link || '#') + '" class="J_nav ' + (content_link ? 'J_has-content ' : '') + 'folder">' + node.display_name + '</a>';

html += tools.nav(node, current_doc, config);

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "document",
"version": "0.3.1",
"version": "0.3.2",
"description": "Create your document site with just one command.",
"// main": "index.js",
"bin": {
Expand Down
27 changes: 0 additions & 27 deletions test/repo/doc/config.json

This file was deleted.

0 comments on commit b5fae99

Please sign in to comment.