From 3896f90c5e60a29b718370072c909455b0e68458 Mon Sep 17 00:00:00 2001 From: HerrHase Date: Tue, 10 Jan 2023 17:09:57 +0100 Subject: [PATCH] adding #6 --- example/site/site.yml | 3 ++- example/views/rss.njk | 44 +++++++++++++++++++---------------------- src/engines/nunjucks.js | 7 +++++-- test.js | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/example/site/site.yml b/example/site/site.yml index b95c95e..cd3cbb5 100644 --- a/example/site/site.yml +++ b/example/site/site.yml @@ -1,4 +1,5 @@ title: "test" language: "en" domain: "test.io" -https: true \ No newline at end of file +https: true +description: "why" \ No newline at end of file diff --git a/example/views/rss.njk b/example/views/rss.njk index b7a02bc..8b41fc1 100644 --- a/example/views/rss.njk +++ b/example/views/rss.njk @@ -1,13 +1,9 @@ {% set posts = pageQuery.find({ orderBy: [ '-date_published' ], limit: 10, filter: { view: { _eq: 'post.njk' } } }) %} - {% set http = 'http' %} - {% if (site.https) %} {% set http = 'https' %} {% endif %} - - -1 https://gitea.node001.net/HerrHase/siteomat-webpack-plugin {% for post in posts %} - - {{ post.title }} - {{ http }}://{{ site.domain }}{{ post.path }} - {{ dayjs(post.date_published) }} - - {% if post.excerpt %} - - {{ post.excerpt }} - - {% endif %} - - - - - - {{ http }}://{{ site.domain }}{{ post.path }} - + + {{ post.title }} + {{ http }}://{{ site.domain }}{{ post.path }} + {{ dayjs(post.date_published) }} + + {% if post.excerpt %} + + {{ post.excerpt }} + + {% endif %} + + + + + + {{ http }}://{{ site.domain }}{{ post.path }} + {% endfor %} \ No newline at end of file diff --git a/src/engines/nunjucks.js b/src/engines/nunjucks.js index 1c5247e..a1dcbdd 100644 --- a/src/engines/nunjucks.js +++ b/src/engines/nunjucks.js @@ -78,12 +78,15 @@ class Engine { const options = configStore.get('options') // if options minifyHtml is set, minify html - if (options.minifyHtml === true) { + if (options.minifyHtml === true && data.page.type === 'html') { response = minify(response, { removeComments: true, collapseWhitespace: true, - collapseInlineTagWhitespace: true + keepClosingSlash: true, + removeOptionalTags: false }) + } else { + response = response.replace(/^(?:[\t ]*(?:\r?\n|\r))+/gm, '') } done(error, response) diff --git a/test.js b/test.js index 2cb7df6..842abee 100644 --- a/test.js +++ b/test.js @@ -2,7 +2,7 @@ const Siteomat = require('./src/siteomat.js') const siteomat = new Siteomat('./example/site', './example/views', { 'destination': './public', - 'minifyHtml': false + 'minifyHtml': true }) siteomat.run() \ No newline at end of file