Skip to content

Commit

Permalink
fix: add missing waline options
Browse files Browse the repository at this point in the history
  • Loading branch information
bennyxguo committed Aug 2, 2023
1 parent 8210a32 commit 25f732f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ waline:
meta: ['nick', 'mail']
requiredMeta: ['nick', 'mail']
commentSorting: 'latest'
wordLimit: 0
imageUploader: false
pageSize: 10
serverURL: '' # 填写服务端地址

# Enable Busuanzi statistic plugin
Expand Down
10 changes: 8 additions & 2 deletions src/components/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ export default defineComponent({
reaction,
meta,
requiredMeta,
commentSorting
commentSorting,
wordLimit,
imageUploader,
pageSize
} = appStore.themeConfig.plugins.waline
waline = walineInit({
Expand All @@ -150,7 +153,10 @@ export default defineComponent({
reaction,
meta,
requiredMeta,
commentSorting
commentSorting,
wordLimit,
imageUploader,
pageSize
})
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/models/ThemeConfig.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@ export interface PluginsData {
login: string
meta: string[] | never[]
requiredMeta: string[] | never[]
imageUploader?: boolean
wordLimit: number | number[]
pageSize: number
commentSorting: string
}

Expand Down Expand Up @@ -546,6 +549,9 @@ export class Plugins implements PluginsData {
login: 'disable',
meta: [],
requiredMeta: [],
imageUploader: false,
wordLimit: 0,
pageSize: 10,
commentSorting: 'latest'
}
recent_comments = false
Expand Down
24 changes: 19 additions & 5 deletions src/utils/comments/waline-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,41 @@ interface WalineComment {
user_id: number | null
}

interface WalineInitOptions extends WalineConfig {
el: string
dark: string
locale: string
}

export const walineInit = ({
serverURL,
lang = 'en',
reaction = false,
login = 'disable',
meta,
requiredMeta,
commentSorting
commentSorting,
wordLimit,
imageUploader,
pageSize
}: Partial<WalineConfig>) => {
return init({
let options: Partial<WalineInitOptions> = {
el: '#waline',
dark: 'body[class="theme-dark"]',
reaction,
serverURL,
lang,
login,
local: 'zh-CN',
locale: 'zh-CN',
meta,
requiredMeta,
commentSorting
})
commentSorting,
wordLimit,
pageSize
}

if (imageUploader === false) options = { imageUploader, ...options }
return init(options)
}

export class WalineComments {
Expand Down

0 comments on commit 25f732f

Please sign in to comment.