You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
472 B
JavaScript
18 lines
472 B
JavaScript
/**
|
|
* Capitalize the first letter of comment name
|
|
*/
|
|
|
|
hexo.extend.filter.register('before_generate', () => {
|
|
const themeConfig = hexo.theme.config
|
|
let { use } = themeConfig.comments
|
|
if (!use) return
|
|
|
|
// 確保 use 是一個陣列
|
|
use = Array.isArray(use) ? use : use.split(',')
|
|
|
|
// 將每個項目轉換為小寫並將首字母大寫
|
|
themeConfig.comments.use = use.map(item =>
|
|
item.trim().toLowerCase().replace(/\b[a-z]/g, s => s.toUpperCase())
|
|
)
|
|
})
|