From bbab557d8eb3837d9ed54742fba310ad68abc347 Mon Sep 17 00:00:00 2001 From: HerrHase Date: Mon, 13 Mar 2023 20:06:41 +0100 Subject: [PATCH] adding #11 --- package.json | 2 +- ressources/index.md | 1 + src/factories/sitemap.js | 10 ++-------- test/parserMarkdown.js | 3 ++- test/sitemap.js | 4 ++++ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index d72dbc1..78b92f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@site-o-mat/core", - "version": "0.3.1", + "version": "0.3.2", "build": "webpack", "author": "Björn Hase ", "main": "index.js", diff --git a/ressources/index.md b/ressources/index.md index de99570..d4def82 100644 --- a/ressources/index.md +++ b/ressources/index.md @@ -3,6 +3,7 @@ title: "health goth DIY tattooed" view: "page.njk" meta: description: "DSA yes plz hot chicken green juice" + robots: "noindex" media: src: src: '_images/dog.jpg' diff --git a/src/factories/sitemap.js b/src/factories/sitemap.js index 6a82934..09a4619 100644 --- a/src/factories/sitemap.js +++ b/src/factories/sitemap.js @@ -59,14 +59,8 @@ class Sitemap { let result = true - if (page.meta) { - page.meta = Object.entries(page.meta) - page.meta.forEach((meta) => { - if (meta['name'] === 'robots' && meta['content'].includes('noindex')) { - result = false - return; - } - }) + if (page.meta && page.meta.robots && page.meta.robots.includes('noindex')) { + result = false } if (page.extensions !== 'html') { diff --git a/test/parserMarkdown.js b/test/parserMarkdown.js index c84eaa9..43ac577 100644 --- a/test/parserMarkdown.js +++ b/test/parserMarkdown.js @@ -39,7 +39,8 @@ describe('Parser Markdown', function () { title: 'health goth DIY tattooed', view: 'page.njk', meta: { - description: 'DSA yes plz hot chicken green juice' + description: 'DSA yes plz hot chicken green juice', + robots: 'noindex' } }) }) diff --git a/test/sitemap.js b/test/sitemap.js index 41874e7..666f9b0 100644 --- a/test/sitemap.js +++ b/test/sitemap.js @@ -27,4 +27,8 @@ describe('Sitemap', function () { it('loc-tag with url', function() { assert.match(sitemap.getXmlAsString(), /https:\/\/test.lan\/blog\/article.html<\/loc>/) }) + + it('loc-tag has robotos:noindex and has missing', function() { + assert.notMatch(sitemap.getXmlAsString(), /https:\/\/test.lan\/index.html<\/loc>/) + }) })