Skip to content

Commit

Permalink
add support for posts without tags
Browse files Browse the repository at this point in the history
  • Loading branch information
nickschot committed Nov 12, 2020
1 parent e010d58 commit b729fb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ Please generate tags using 'ember generate tag your-tag-name'`);
const fileContents = readFileSync(join(appPrefix, 'content', file))
const frontMatter = yamlFront.loadFront(fileContents);

postTags.push(frontMatter.tags);
if (frontMatter.tags) {
postTags.push(frontMatter.tags);
}
});

postTags = _.chain(postTags)
Expand Down
8 changes: 6 additions & 2 deletions lib/automatic-new-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,21 @@ module.exports = class AutomaticNewTag extends BroccoliPlugin {

_.chain(markdownFiles)
.map((file) => {
const fileContents = readFileSync(join(dir, file))
const fileContents = readFileSync(join(dir, file));
return {
frontMatter: yamlFront.loadFront(fileContents),
file,
}
};
})
.sortBy(({frontMatter}) => {
return new Date(frontMatter.date);
})
.reverse()
.forEach(({file, frontMatter}, index) => {
if (!frontMatter.tags) {
frontMatter.tags = [];
}

if (frontMatter.tags.includes('new')) {
// eslint-disable-next-line no-console
console.warn(`The tag "new" is deprecated, "new" is automatically added as a tag to the 4 most recent posts now. File: ${file}`);
Expand Down

0 comments on commit b729fb1

Please sign in to comment.