vuepress-plugin-twikoo 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/Comment.vue +24 -1
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/Comment.vue CHANGED
@@ -7,6 +7,19 @@ export default {
7
7
  mounted() {
8
8
  // 检查是否在浏览器环境中
9
9
  if (typeof window !== 'undefined') {
10
+ // 如果指定了容器,将评论组件移动到指定位置
11
+ if (TWIKOO_CONTAINER && TWIKOO_CONTAINER !== '#tcomment') {
12
+ const targetContainer = document.querySelector(TWIKOO_CONTAINER)
13
+ if (targetContainer) {
14
+ // 将评论容器移动到目标位置(不清空目标容器,与现有内容共存)
15
+ const commentContainer = document.getElementById('tcomment')
16
+ if (commentContainer) {
17
+ targetContainer.appendChild(commentContainer)
18
+ }
19
+ } else {
20
+ console.warn(`Twikoo target container not found: ${TWIKOO_CONTAINER}`)
21
+ }
22
+ }
10
23
  this.initTwikoo()
11
24
  }
12
25
 
@@ -16,6 +29,16 @@ export default {
16
29
  }
17
30
  // 检查是否在浏览器环境中
18
31
  if (typeof window !== 'undefined') {
32
+ // 重新定位评论组件
33
+ if (TWIKOO_CONTAINER && TWIKOO_CONTAINER !== '#tcomment') {
34
+ const targetContainer = document.querySelector(TWIKOO_CONTAINER)
35
+ if (targetContainer) {
36
+ const commentContainer = document.getElementById('tcomment')
37
+ if (commentContainer && commentContainer.parentNode !== targetContainer) {
38
+ targetContainer.appendChild(commentContainer)
39
+ }
40
+ }
41
+ }
19
42
  this.initTwikoo()
20
43
  }
21
44
  })
@@ -35,7 +58,7 @@ export default {
35
58
  const twikoo = await import('twikoo')
36
59
  twikoo.init({
37
60
  ...TWIKOO_OPTIONS,
38
- el: TWIKOO_CONTAINER || '#tcomment'
61
+ el: '#tcomment'
39
62
  })
40
63
  },
41
64
  needComment(frontmatter) {
package/index.js CHANGED
@@ -7,6 +7,6 @@ module.exports = (opts, ctx) => {
7
7
  TWIKOO_CONTAINER: opts.container || 'main.page'
8
8
  },
9
9
  enhanceAppFiles: path.resolve(__dirname, 'comment.js'),
10
- globalUIComponents: 'Comment'
10
+ globalUIComponents: opts.global !== false ? 'Comment' : undefined
11
11
  }
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vuepress-plugin-twikoo",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Twikoo comment plugin for vuepress 1.x",
5
5
  "main": "index.js",
6
6
  "scripts": {