Skip to content

Commit

Permalink
minor update to lint script
Browse files Browse the repository at this point in the history
  • Loading branch information
dogle-scottlogic committed Nov 18, 2024
1 parent ccfb1a8 commit c28305e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lintPosts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const matter = require("gray-matter");
const yaml = require("js-yaml");
const fs = require("fs");
const { exit } = require("process");
const LINTER_MATCH_PATTERN="_posts/**/*.{md,markdown,html}"
const LINTER_MATCH_PATTERN="_posts/**/*.{md,markdown,html}";
const MAX_CATEGORIES = 3;

const flatMap = (arr, mapFunc) =>
arr.reduce((prev, x) => prev.concat(mapFunc(x)), []);
Expand Down Expand Up @@ -72,10 +73,10 @@ const lintPosts = () => {
category = frontMatter.data.category.toLowerCase();
// if the frontmatter defines a 'categories' field with at least one but no more than 3 values:

} else if (frontMatterCats && frontMatterCats.length && frontMatterCats.length <= 3) {
} else if (frontMatterCats && frontMatterCats.length && frontMatterCats.length <= MAX_CATEGORIES) {
category = frontMatter.data.categories[0].toLowerCase();
} else {
console.error("The post " + path + " does not have at least one but no more than 3 categories defined");
console.error("The post " + path + " does not have at least one and no more than " + MAX_CATEGORIES + " categories defined.");
fail = true;
return;
}
Expand Down

0 comments on commit c28305e

Please sign in to comment.