From a1615e36c566995ab30596387d5e5498d4c29cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Sko=C5=99epa?= <jakub@skorepa.info> Date: Sat, 26 Mar 2016 20:31:31 +0100 Subject: [PATCH] =?UTF-8?q?Implement=20autotagging=20with=20=C4=8Cl=C3=A1n?= =?UTF-8?q?ek?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit metadata to disable: `notarticle = true` Also simplified theme.js and writeFiles.js which also fixed weird bug Fixes #22 --- sitegin/tags.js | 11 +++++++++++ sitegin/theme.js | 7 ++----- sitegin/writeFiles.js | 6 ++---- theme/templates/partials/list.html.nunj | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/sitegin/tags.js b/sitegin/tags.js index 86390ce..42b14af 100644 --- a/sitegin/tags.js +++ b/sitegin/tags.js @@ -12,7 +12,18 @@ module.exports = function(obj) { var tags = []; var tagPages = {}; obj.pages.forEach(function(article) { + if(!article.metadata.tags && !article.metadata.notarticle) { + article.metadata.tags = [ 'Článek' ]; + } if(article.metadata.tags) { + if(!article.metadata.notarticle) { + var hasarticletag = false; + article.metadata.tags.forEach(function(tag) { + if(toURL(tag) == 'clanek') hasarticletag = true; + }) + if(!hasarticletag) article.metadata.tags.push('Článek'); + } + var ntags = []; article.metadata.tags.forEach(function(tag) { tag = { diff --git a/sitegin/theme.js b/sitegin/theme.js index 1b00c18..bb743ea 100644 --- a/sitegin/theme.js +++ b/sitegin/theme.js @@ -11,12 +11,9 @@ module.exports = function(obj) { todo++; jobs.run('nunjucks', obj, type) .then(function(data) { + if(!obj.rendered) obj.rendered = []; data.forEach(function(o){ - if(o.type == 'html') obj.content = o.content; - else { - if(!obj.otherContent) obj.otherContent = []; - obj.otherContent.push(o); - } + obj.rendered.push(o); }); done(); diff --git a/sitegin/writeFiles.js b/sitegin/writeFiles.js index 781dbd7..7fbfa8b 100644 --- a/sitegin/writeFiles.js +++ b/sitegin/writeFiles.js @@ -20,10 +20,8 @@ module.exports = function(obj) { } var writeFile = function(article) { - var filename = path.join(builddir,article.file,'index.html'); - doWrite(filename, article.content); - if(article.otherContent) { - article.otherContent.forEach(function(o) { + if(article.rendered) { + article.rendered.forEach(function(o) { var f = path.join(builddir,article.file,'index.'+o.type); doWrite(f, o.content); }) diff --git a/theme/templates/partials/list.html.nunj b/theme/templates/partials/list.html.nunj index 71717a8..c0ba051 100644 --- a/theme/templates/partials/list.html.nunj +++ b/theme/templates/partials/list.html.nunj @@ -22,7 +22,7 @@ {{page.metadata.perex_e | truncate}} {% else %} {% if page.content %} - {{ page.content | string | striptags | truncate }} + {{ page.content | striptags | truncate }} {% endif %} {% endif %} {% endif %} -- GitLab