mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2025-09-15 12:58:48 +08:00
improvement: tags 設定彩色顯示後,字型大小將根據tag的文章數量而變化 close #365
improvement: 調整tags頁和categories頁在寬度小於768時的字體大小
This commit is contained in:
parent
97bb8313d0
commit
938e7a04c7
@ -7,7 +7,7 @@ block content
|
|||||||
| -
|
| -
|
||||||
span.tag-cloud__amount= site.tags.length
|
span.tag-cloud__amount= site.tags.length
|
||||||
.tag-cloud-tags
|
.tag-cloud-tags
|
||||||
!=cloudTags({source: site.tags, minfontsize: 1, maxfontsize: 2.1, limit: 0, unit: 'em'})
|
!=cloudTags({source: site.tags, minfontsize: 1.2, maxfontsize: 2.1, limit: 0, unit: 'em'})
|
||||||
if page.comments !== false && theme.comments && theme.comments.use
|
if page.comments !== false && theme.comments && theme.comments.use
|
||||||
- var commentsJsLoad = true
|
- var commentsJsLoad = true
|
||||||
!=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache})
|
!=partial('includes/third-party/comments/index', {}, {cache:theme.fragment_cache})
|
||||||
|
|||||||
@ -3,7 +3,7 @@ extends includes/layout.pug
|
|||||||
block content
|
block content
|
||||||
if theme.tag_ui == 'index'
|
if theme.tag_ui == 'index'
|
||||||
include ./includes/mixins/post-ui.pug
|
include ./includes/mixins/post-ui.pug
|
||||||
#recent-posts.recent-posts
|
#recent-posts.recent-posts
|
||||||
+postUI
|
+postUI
|
||||||
include includes/pagination.pug
|
include includes/pagination.pug
|
||||||
else
|
else
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hexo-theme-butterfly",
|
"name": "hexo-theme-butterfly",
|
||||||
"version": "3.2.0-b3",
|
"version": "3.2.0-b4",
|
||||||
"description": "A Simple and Card UI Design theme for Hexo",
|
"description": "A Simple and Card UI Design theme for Hexo",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -34,19 +34,32 @@ hexo.extend.helper.register('injectHtml', function (data) {
|
|||||||
|
|
||||||
hexo.extend.helper.register('cloudTags', function (options = {}) {
|
hexo.extend.helper.register('cloudTags', function (options = {}) {
|
||||||
const env = this
|
const env = this
|
||||||
const source = options.source
|
let source = options.source
|
||||||
const minfontsize = options.minfontsize
|
const minfontsize = options.minfontsize
|
||||||
const maxfontsize = options.maxfontsize
|
const maxfontsize = options.maxfontsize
|
||||||
const limit = options.limit
|
const limit = options.limit
|
||||||
const unit = options.unit || 'px'
|
const unit = options.unit || 'px'
|
||||||
|
|
||||||
let result = ''
|
let result = ''
|
||||||
const tagLimit = limit === 0 ? source.length : limit
|
if (limit > 0) {
|
||||||
source.sort('name').limit(tagLimit).forEach(function (tags) {
|
source = source.limit(limit)
|
||||||
const fontSizeRD = Math.random() * (maxfontsize - minfontsize) + minfontsize
|
}
|
||||||
const fontSize = fontSizeRD.toFixed(2) + unit
|
|
||||||
|
const sizes = []
|
||||||
|
source.sort('length').forEach(tag => {
|
||||||
|
const { length } = tag
|
||||||
|
if (sizes.includes(length)) return
|
||||||
|
sizes.push(length)
|
||||||
|
})
|
||||||
|
|
||||||
|
const length = sizes.length - 1
|
||||||
|
source.forEach(tag => {
|
||||||
|
const ratio = length ? sizes.indexOf(tag.length) / length : 0
|
||||||
|
const size = minfontsize + ((maxfontsize - minfontsize) * ratio)
|
||||||
|
let style = `font-size: ${parseFloat(size.toFixed(2))}${unit};`
|
||||||
const color = 'rgb(' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ')' // 0,0,0 -> 200,200,200
|
const color = 'rgb(' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ', ' + Math.floor(Math.random() * 201) + ')' // 0,0,0 -> 200,200,200
|
||||||
result += `<a href='${env.url_for(tags.path)}' style='font-size:${fontSize}; color:${color}'>${tags.name}</a>`
|
style += ` color: ${color}`
|
||||||
|
result += `<a href="${env.url_for(tag.path)}" style="${style}">${tag.name}</a>`
|
||||||
})
|
})
|
||||||
return result
|
return result
|
||||||
})
|
})
|
||||||
|
|||||||
@ -9,6 +9,9 @@
|
|||||||
text-align: center
|
text-align: center
|
||||||
font-size: 2.57em
|
font-size: 2.57em
|
||||||
|
|
||||||
|
+maxWidth768()
|
||||||
|
font-size: 2em
|
||||||
|
|
||||||
.category-list
|
.category-list
|
||||||
a
|
a
|
||||||
color: var(--font-color)
|
color: var(--font-color)
|
||||||
|
|||||||
@ -10,5 +10,11 @@
|
|||||||
color: $text-hover !important
|
color: $text-hover !important
|
||||||
transform: scale(1.1)
|
transform: scale(1.1)
|
||||||
|
|
||||||
|
+maxWidth768()
|
||||||
|
zoom: .85
|
||||||
|
|
||||||
&__title
|
&__title
|
||||||
font-size: 2.57em
|
font-size: 2.57em
|
||||||
|
|
||||||
|
+maxWidth768()
|
||||||
|
font-size: 2em
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user