mirror of
https://github.com/jerryc127/hexo-theme-butterfly.git
synced 2026-04-16 20:20:53 +08:00
fix: 更新 package.json 和 plugins.yml 中的版本號
fix: 修正 truncateContent 函數, 加密文章不显示自动擷取內容 feat: 增加首頁樣式以支持單詞換行 fix: 修正 truncateContent 函數以正確處理自動擷取內容 fix: 修复 card_archives 计数 bug fix: 修正分頁順序邏輯
This commit is contained in:
@@ -3,13 +3,14 @@
|
||||
const { stripHTML, truncate } = require('hexo-util')
|
||||
|
||||
// Truncates the given content to a specified length, removing HTML tags and replacing newlines with spaces.
|
||||
const truncateContent = (content, length) => {
|
||||
return truncate(stripHTML(content), { length, separator: ' ' }).replace(/\n/g, ' ')
|
||||
const truncateContent = (content, length, encrypt = false) => {
|
||||
if (!content || encrypt) return ''
|
||||
return truncate(stripHTML(content).replace(/\n/g, ' '), { length })
|
||||
}
|
||||
|
||||
// Generates a post description based on the provided data and theme configuration.
|
||||
const postDesc = (data, hexo) => {
|
||||
const { description, content, postDesc } = data
|
||||
const { description, content, postDesc, encrypt } = data
|
||||
|
||||
if (postDesc) return postDesc
|
||||
|
||||
@@ -23,10 +24,10 @@ const postDesc = (data, hexo) => {
|
||||
result = description
|
||||
break
|
||||
case 2:
|
||||
result = description || truncateContent(content, length)
|
||||
result = description || truncateContent(content, length, encrypt)
|
||||
break
|
||||
default:
|
||||
result = truncateContent(content, length)
|
||||
result = truncateContent(content, length, encrypt)
|
||||
}
|
||||
|
||||
data.postDesc = result
|
||||
|
||||
Reference in New Issue
Block a user