Skip to content
Snippets Groups Projects
Verified Commit a1615e36 authored by Isabella Skořepová's avatar Isabella Skořepová
Browse files

Implement autotagging with Článek

metadata to disable: `notarticle = true`

Also simplified theme.js and writeFiles.js which also fixed weird bug
Fixes #22
parent e040dc85
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -12,7 +12,18 @@ module.exports = function(obj) { ...@@ -12,7 +12,18 @@ module.exports = function(obj) {
var tags = []; var tags = [];
var tagPages = {}; var tagPages = {};
obj.pages.forEach(function(article) { obj.pages.forEach(function(article) {
if(!article.metadata.tags && !article.metadata.notarticle) {
article.metadata.tags = [ 'Článek' ];
}
if(article.metadata.tags) { 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 = []; var ntags = [];
article.metadata.tags.forEach(function(tag) { article.metadata.tags.forEach(function(tag) {
tag = { tag = {
......
...@@ -11,12 +11,9 @@ module.exports = function(obj) { ...@@ -11,12 +11,9 @@ module.exports = function(obj) {
todo++; todo++;
jobs.run('nunjucks', obj, type) jobs.run('nunjucks', obj, type)
.then(function(data) { .then(function(data) {
if(!obj.rendered) obj.rendered = [];
data.forEach(function(o){ data.forEach(function(o){
if(o.type == 'html') obj.content = o.content; obj.rendered.push(o);
else {
if(!obj.otherContent) obj.otherContent = [];
obj.otherContent.push(o);
}
}); });
done(); done();
......
...@@ -20,10 +20,8 @@ module.exports = function(obj) { ...@@ -20,10 +20,8 @@ module.exports = function(obj) {
} }
var writeFile = function(article) { var writeFile = function(article) {
var filename = path.join(builddir,article.file,'index.html'); if(article.rendered) {
doWrite(filename, article.content); article.rendered.forEach(function(o) {
if(article.otherContent) {
article.otherContent.forEach(function(o) {
var f = path.join(builddir,article.file,'index.'+o.type); var f = path.join(builddir,article.file,'index.'+o.type);
doWrite(f, o.content); doWrite(f, o.content);
}) })
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
{{page.metadata.perex_e | truncate}} {{page.metadata.perex_e | truncate}}
{% else %} {% else %}
{% if page.content %} {% if page.content %}
{{ page.content | string | striptags | truncate }} {{ page.content | striptags | truncate }}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endif %} {% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment