jerryc127 / hexo-theme-butterfly

🦋 A Hexo Theme: Butterfly
https://butterfly.js.org
Apache License 2.0
7.07k stars 1.28k forks source link

[Feature]: 侧边栏标签云显示逻辑陈旧 #1178

Closed Pil0tXia closed 1 year ago

Pil0tXia commented 1 year ago

想要的功能 | What feature do you want?

aside.card_tags 属性,若用户有一百多个标签,limit设置为40,就只会显示前40个标签,也就总是显示前几篇文章的标签。

建议优先按全局所有标签的出现频率显示标签,其他出现频率一致的标签则优先显示新的标签。

jerryc127 commented 1 year ago

我觉得现在的就很好 把文章中使用的标签最多的 从多到少排序

Pil0tXia commented 1 year ago

但是我发现除了那些频率高的标签,其他标签都是我第一、二、三篇文章用的标签,而不是我新发的文章的标签。

jerryc127 commented 1 year ago

我不清楚 hexo 这个参数的逻辑 估计相同数量的标签 按首字母排序吧

Pil0tXia commented 1 year ago

不是按照首字母的,是按照时间顺序,从旧到新。可以改成从新到旧吗

jerryc127 commented 1 year ago

https://hexo.io/zh-tw/docs/helpers#tagcloud

没这个参数设置

Pil0tXia commented 1 year ago

这个链接应该是针对文章设置的,不是全站

jerryc127 commented 1 year ago

这个链接应该是针对文章设置的,不是全站

你确定看了么

这是生成标签云

主题就是调用这个

Pil0tXia commented 1 year ago

请问该如何修改? 我修改了layout/includes/widget/card_tags.pug的这两行:

        .card-tag-cloud!= cloudTags({source: site.tags, minfontsize: 1.15, maxfontsize: 1.45, limit: tagLimit, order: -1, unit: 'em'})
      else
        .card-tag-cloud!= tagcloud({min_font: 1.0, max_font: 1.4, amount: tagLimit, color: true, start_color: '#999', end_color: '#99a9bf', unit: 'em'})

order:-1/1和orderby:name/random/length参数没有对生成的结果产生影响,始终都是前几篇文章的tag在最前面。 把cloudTags换成tagcloud也是如此

jerryc127 commented 1 year ago

你看清楚啊 有个if判断 看你是那种 如果你要修改 cloudtags 的参数 自己去修改 https://github.com/jerryc127/hexo-theme-butterfly/blob/08fabdc2d14c3f6d52f0193c709313eed21b5c07/scripts/helpers/page.js#L25-L55

Pil0tXia commented 1 year ago

我注意到if了,去掉判断直接写.card-tag-cloud! = tagcloud({min_font: 0.95, max_font: 1.35, amount: tagLimit, orderby: count, order: -1, color: true, start_color: '#999', end_color: '#99a9bf', unit: 'em'})的结果和orderby: name, order: 1,没有区别,已经尝试了好几种不同的组合

jerryc127 commented 1 year ago

默認 Snipaste_2023-02-05_15-19-57

改了 .card-tag-cloud!= tagcloud({orderby: 'length', min_font: 1.1, max_font: 1.5, amount: tagLimit , color: true, start_color: '#999', end_color: '#99a9bf', unit: 'em'}) Snipaste_2023-02-05_15-21-07

orderby 是 string 加引號

Pil0tXia commented 1 year ago

谢谢提醒,.card-tag-cloud!= tagcloud({min_font: 0.9, max_font: 1.35, amount: tagLimit, orderby: 'length', order: -1, color: true, start_color: '#999', end_color: '#99a9bf', unit: 'em'})可以实现全局最常用标签排最前面的效果,还要再加一个order: -1