Skip to content

Commit

Permalink
[fix] Clean up metadata view if metadata doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
jfhbrook committed Nov 5, 2011
1 parent cba4594 commit 83a7213
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# docs

http://docs.nodejitsu.com

**community powered rocket-fuel for node.js**
Expand Down
36 changes: 18 additions & 18 deletions lib/generators/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@ content.weld = function(dom, pages) {
// Here, we build up the table of contents.
var toc = helpers.buildToc(docs.src);

/*console.log((function () {
var sorts = {};
Object.keys(pages).forEach( function (i) {
if (pages[i].metadata && pages[i].metadata.order) {
Object.keys(pages[i].metadata.order).forEach(function (j) {
sorts[i+"/"+j] = pages[i].metadata.order[j];
});
}
});
return fs2.filesToTree(sorts);
})());*/

Object.keys(pages).forEach( function (i) {

// parse content if it exists
Expand Down Expand Up @@ -112,12 +100,9 @@ content.weld = function(dom, pages) {
//Handle dates
if ($(element).hasClass("date")) {
var date = val ? new Date(val).toISOString() : undefined;
if (val) {
if (date) {
$(element).attr("datetime", new Date(val).toISOString());
$(element).text(val);
} else {
//TODO: If there isn't any metadata, we shouldn't have the
//"by x on y" div.
}
return false;
}
Expand All @@ -140,11 +125,26 @@ content.weld = function(dom, pages) {

});

// we need to clean up dom elements if metadata is missing
if (typeof metadata.title === "undefined") {
$("#metadata .title", dom).remove();
};
if (typeof metadata.date === "undefined") {
$("#metadata .date", dom).parent().parent().parent().remove();
};




//if (!metadata.date) {
// console.log("no date!");
// $('.date').parent().remove();
//}

//Give the page a title
// Give the page a title
$('title', dom).html('node docs - ' + (metadata && metadata.title) || "");

//Add some meta tags
// Add some meta tags
$('meta[name=keywords]', dom).attr('content',
(metadata && metadata.tags || [])
.concat(docs.config.get("tags") || []).join(',')
Expand Down
3 changes: 0 additions & 3 deletions pages/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"title":"Docs",
"date": "Thu Oct 20 16:56:11 PDT 2011",
"author": "Nodejitsu",
"difficulty": 1,
"index": false,
"order": {
Expand Down
2 changes: 1 addition & 1 deletion theme/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<article id="article">
<div id="metadata">
<h1 class="title"></h1>
by <strong class="author"><span class="name"></span> <span class="github"></span></strong> on <em><time class="date"></time></em>
<span class="about">by <strong class="author"><span class="name"></span> <span class="github"></span></span><span class="about"></strong> on <em><time class="date"></time></em></span>
<nav class="breadcrumbs">
<a href="" class="breadcrumb"></a>
</nav>
Expand Down

0 comments on commit 83a7213

Please sign in to comment.