Advertisement
Guest User

Untitled

a guest
May 24th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. const tagData = tags.data.data.items;
  2.  
  3. // Logic for returning scaled font sizes for the tag cloud
  4. const initialValue = 0;
  5. const highest = tagData.reduce((accumulator, currentValue) =>
  6. Math.max(accumulator, currentValue.term_count), initialValue),
  7. lowest = tagData.reduce((accumulator, currentValue) =>
  8. Math.min(accumulator, currentValue.term_count), highest),
  9. range = highest - lowest;
  10.  
  11. const sizeEnd = (config.has('blog.tagcloudMaxSize')) ? (config.get('blog.tagcloudMaxSize')) : 22;
  12. const sizeStart = (config.has('blog.tagcloudMinSize')) ? (config.get('blog.tagcloudMinSize')) : 14;
  13. const increment = (sizeEnd - sizeStart) / range;
  14.  
  15. tagData.map(tagItem => {
  16. const weighting = tagItem.term_count - lowest;
  17. tagItem.fontsize = (sizeStart + (weighting * increment));
  18. return tagItem;
  19. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement