diff --git a/sitegin/input-hugo.js b/sitegin/input-hugo.js index abd9a69d9ed2bb2e6ec53cb54fe1007a514e06ad..a1725dcd23570e2c08084c28d87634b26a62e0b3 100644 --- a/sitegin/input-hugo.js +++ b/sitegin/input-hugo.js @@ -19,15 +19,17 @@ function walk(currentDirPath, callback, end_cb) { if(err!=null) console.log(err); files.forEach(function(name) { var filePath = path.join(currentDirPath, name); - var stat = fs.statSync(filePath); - if (stat.isFile()) { - callback(filePath, stat); - } else if (stat.isDirectory()) { - if(filePath.indexOf(".git") < 0) { - subcalls++; - walk(filePath, callback, ender); + try { + var stat = fs.statSync(filePath); + if (stat.isFile()) { + callback(filePath, stat); + } else if (stat.isDirectory()) { + if(filePath.indexOf(".git") < 0) { + subcalls++; + walk(filePath, callback, ender); + } } - } + } catch(e) {} }); if(subcalls == 0) ender(); @@ -88,6 +90,8 @@ module.exports = function(_contentDir) { */ exports.forEachPage = function(callback, cb_end) { walk(contentDir+"articles",function(filePath, stat) { + console.log(filePath, path.basename(filePath)); + if(path.basename(filePath).substr(0,1) == ".") return; if(callback !== undefined) callback(filePath.substring(contentDir.length,filePath.length-3)); }, function() { if(cb_end !== undefined) cb_end(); diff --git a/sitegin/transformer-git.js b/sitegin/transformer-git.js index c4488c9368de2598ecf54d0e70dfb03e93bb9b9e..bb0dc377cde042a26bb8fe8754956016518e21f2 100644 --- a/sitegin/transformer-git.js +++ b/sitegin/transformer-git.js @@ -84,10 +84,10 @@ module.exports = function() { articleList.forEach(function(article) { var file = path.relative(pathToRepo, article.origFile); var commits = filesHistory[file]; - commits.sort(function(a,b){ - return b.date - a.date; - }); if(commits !== undefined) { + commits.sort(function(a,b){ + return b.date - a.date; + }); var newestCommit = commits[0]; var oldestCommit = commits[commits.length-1]; diff --git a/sitegin/transformer-markdown.js b/sitegin/transformer-markdown.js index 7f549d7bc8a457f6de506d12511b67cded7e5b2b..abaf3e563ef5f21c907d1f07b11a4ab5259e04ce 100644 --- a/sitegin/transformer-markdown.js +++ b/sitegin/transformer-markdown.js @@ -24,6 +24,11 @@ renderer.heading = function(text, level, raw) { + '>\n'; } +renderer.paragraph = function(text) { + if(text.match('\\<img')) return '<div class="has-image">'+text+'</div>\n'; + else return '<p>'+text+'</p>\n'; +} + marked.setOptions({ renderer: renderer, gfm: true, @@ -49,6 +54,9 @@ module.exports = function() { article.origContent = article.content; renderer.image = function(href, title, text) { href = href.split(path.sep).join("/"); + href = href.split(" ="); + var size = href[1]; + href = href[0]; var rel = path.relative(process.cwd(),path.resolve(article.file,href)); rel = rel.split(path.sep).join("/"); var img = images[rel]; @@ -68,6 +76,15 @@ module.exports = function() { } var out = '<img src="' + href + '" alt="' + text + '"'; + if(size !== undefined) { + size = size.split('x'); + if(size[0].length > 0) { + out += ' width="' + size[0] + '"'; + } + if(size.length > 1 && size[1].length > 0) { + out += ' height="' + size[1] + '"'; + } + } if (title) { out += ' title="' + title + '"'; }