Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const tagData = tags.data.data.items;
- // Logic for returning scaled font sizes for the tag cloud
- const initialValue = 0;
- const highest = tagData.reduce((accumulator, currentValue) =>
- Math.max(accumulator, currentValue.term_count), initialValue),
- lowest = tagData.reduce((accumulator, currentValue) =>
- Math.min(accumulator, currentValue.term_count), highest),
- range = highest - lowest;
- const sizeEnd = (config.has('blog.tagcloudMaxSize')) ? (config.get('blog.tagcloudMaxSize')) : 22;
- const sizeStart = (config.has('blog.tagcloudMinSize')) ? (config.get('blog.tagcloudMinSize')) : 14;
- const increment = (sizeEnd - sizeStart) / range;
- tagData.map(tagItem => {
- const weighting = tagItem.term_count - lowest;
- tagItem.fontsize = (sizeStart + (weighting * increment));
- return tagItem;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement