fixed extra spacing bug when sorting tags

This commit is contained in:
Ro 2020-05-20 11:51:04 -07:00
parent fad2c4bc8d
commit 8e365216ea

View file

@ -5,8 +5,10 @@ import _ from 'lodash';
import * as DataEvent from '../../src/com/events/DataEvent'; import * as DataEvent from '../../src/com/events/DataEvent';
import Navigation from './Navigation'; import Navigation from './Navigation';
import Settings from './Settings'; import Settings from './Settings';
import StringUtils from '../../src/com/utils/StringUtils';
const nav = new Navigation(); const nav = new Navigation();
const settings = new Settings(); const settings = new Settings();
const utils = new StringUtils();
const moment = require('moment'); const moment = require('moment');
/** /**
* Class for handling blog content pages * Class for handling blog content pages
@ -192,10 +194,15 @@ export default class Pages {
let temp = []; let temp = [];
temp = page.metadata.tags.split(','); temp = page.metadata.tags.split(',');
for (let i = 0; i < temp.length; i++) { for (let i = 0; i < temp.length; i++) {
if (!_.find(tags, { tag_name: temp[i] })) { let label = temp[i];
tags.push({ tag_name: temp[i], count: 1 }); if (!_.find(tags, { tag_name: label.trim() })) {
tags.push({
tag_name: label.trim(),
slug: utils.cleanString(label.trim()),
count: 1
});
} else { } else {
_.find(tags, { tag_name: temp[i] }).count++; _.find(tags, { tag_name: label.trim() }).count++;
} }
} }
} }