From 8e365216eaddcc2517e0ecc34ac25d243c22b849 Mon Sep 17 00:00:00 2001 From: Ro Date: Wed, 20 May 2020 11:51:04 -0700 Subject: [PATCH] fixed extra spacing bug when sorting tags --- brain/data/Book.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/brain/data/Book.js b/brain/data/Book.js index 500ab04..622b752 100644 --- a/brain/data/Book.js +++ b/brain/data/Book.js @@ -5,8 +5,10 @@ import _ from 'lodash'; import * as DataEvent from '../../src/com/events/DataEvent'; import Navigation from './Navigation'; import Settings from './Settings'; +import StringUtils from '../../src/com/utils/StringUtils'; const nav = new Navigation(); const settings = new Settings(); +const utils = new StringUtils(); const moment = require('moment'); /** * Class for handling blog content pages @@ -192,10 +194,15 @@ export default class Pages { let temp = []; temp = page.metadata.tags.split(','); for (let i = 0; i < temp.length; i++) { - if (!_.find(tags, { tag_name: temp[i] })) { - tags.push({ tag_name: temp[i], count: 1 }); + let label = temp[i]; + if (!_.find(tags, { tag_name: label.trim() })) { + tags.push({ + tag_name: label.trim(), + slug: utils.cleanString(label.trim()), + count: 1 + }); } else { - _.find(tags, { tag_name: temp[i] }).count++; + _.find(tags, { tag_name: label.trim() }).count++; } } }