Skip to content

Commit

Permalink
fix(plugin-comment): revert pageview chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed Apr 1, 2024
1 parent 088ab15 commit 238fd6f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion plugins/plugin-comment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
".": "./lib/node/index.js",
"./client": "./lib/client/index.js",
"./client/*": "./lib/client/*",
"./pageview": "./lib/client/composables/pageview.js",
"./pageview": "./lib/client/pageview.js",
"./package.json": "./package.json"
},
"main": "./lib/node/index.js",
Expand Down
20 changes: 0 additions & 20 deletions plugins/plugin-comment/src/client/composables/pageview.ts

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/plugin-comment/src/client/helpers/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const defineCommentConfig = <T extends CommentOptions>(options: T): void => {
}

export const useCommentOptions = <T extends CommentOptions>(): T =>
inject(commentSymbol)!
inject(commentSymbol)! ?? comment

export const defineArtalkConfig = defineCommentConfig<ArtalkOptions>

Expand Down
18 changes: 18 additions & 0 deletions plugins/plugin-comment/src/client/pageview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useWalineOptions } from './helpers/index.js'

export type AbortPageview = (reason?: any) => void
export type UpdatePageview = Promise<AbortPageview | void>

export const updatePageview = async (): UpdatePageview => {
const commentOptions = useWalineOptions()

try {
const { pageviewCount } = await import(
/* webpackMode: "week" */ /* webpackChunkName: "pageview" */ '@waline/client/pageview'
)

return pageviewCount({ serverURL: commentOptions.serverURL })
} catch (err) {
console.error('@waline/client is not installed!')
}
}

0 comments on commit 238fd6f

Please sign in to comment.