'use strict';
const { Component } = require('inferno');
const { cacheComponent } = require('../util/cache');
class Tags extends Component {
render() {
const {
tags,
title,
showCount
} = this.props;
return
;
}
}
module.exports = cacheComponent(Tags, 'widget.tags', props => {
// adapted from hexo/lib/plugins/helper/list_tags.js
const {
helper,
orderBy = 'name',
order = 1,
amount,
show_count = true
} = props;
let tags = props.tags || props.site.tags;
const { url_for, _p } = helper;
if (!tags || !tags.length) {
return null;
}
tags = tags.sort(orderBy, order).filter(tag => tag.length);
if (amount) {
tags = tags.limit(amount);
}
return {
showCount: show_count,
title: _p('common.tag', Infinity),
tags: tags.map(tag => ({
name: tag.name,
count: tag.length,
url: url_for(tag.path)
}))
};
});