fixed extra spacing bug when sorting tags

pull/20/head
Ro 4 years ago
parent fad2c4bc8d
commit 8e365216ea

@ -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++;
} }
} }
} }

Loading…
Cancel
Save