vuepress-plugin-twikoo 1.0.6 → 1.0.8

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 +5 -4
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/Comment.vue CHANGED
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div></div>
2
+ <div id="twikoo"></div>
3
3
  </template>
4
4
 
5
5
  <script>
@@ -43,14 +43,15 @@ export default {
43
43
  const twikoo = await import('twikoo');
44
44
  // 初始化后返回 Promise,确保 DOM 生成完成
45
45
  await twikoo.init({
46
- ...TWIKOO_OPTIONS
46
+ ...TWIKOO_OPTIONS,
47
+ el: TWIKOO_OPTIONS.el || '#twikoo'
47
48
  });
48
49
 
49
50
  this.moveContainerWithRetry();
50
51
  },
51
52
 
52
53
  needComment(frontmatter) {
53
- return frontmatter.twikoo !== false;
54
+ return frontmatter.twikoo !== false || !frontmatter?.permalink.startsWith(TWIKOO_OPTIONS.pathPrefix);
54
55
  },
55
56
 
56
57
  // 基础移动逻辑(抽离成独立函数)
@@ -60,7 +61,7 @@ export default {
60
61
  const targetContainer = document.querySelector(TWIKOO_CONTAINER);
61
62
  if (!targetContainer) return; // 目标容器不存在则返回
62
63
 
63
- const commentContainer = document.querySelector('#twikoo');
64
+ const commentContainer = document.querySelector(TWIKOO_OPTIONS.el || '#twikoo');
64
65
  if (commentContainer) {
65
66
  targetContainer.appendChild(commentContainer);
66
67
  return true; // 移动成功,返回 true
package/index.js CHANGED
@@ -3,7 +3,7 @@ const path = require('path')
3
3
  module.exports = (opts, ctx) => {
4
4
  return {
5
5
  define: {
6
- TWIKOO_OPTIONS: opts.options || {},
6
+ TWIKOO_OPTIONS: opts.options || { pathPrefix: '/pages' },
7
7
  TWIKOO_CONTAINER: opts.container || 'main.page'
8
8
  },
9
9
  enhanceAppFiles: path.resolve(__dirname, 'comment.js'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vuepress-plugin-twikoo",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Twikoo comment plugin for vuepress 1.x",
5
5
  "main": "index.js",
6
6
  "scripts": {