vuepress-plugin-twikoo 1.0.9 → 1.0.11

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 +3 -3
  2. package/index.js +6 -1
  3. package/package.json +1 -1
package/Comment.vue CHANGED
@@ -56,10 +56,10 @@ export default {
56
56
 
57
57
  // 基础移动逻辑(抽离成独立函数)
58
58
  moveContainer() {
59
- if (!TWIKOO_CONTAINER) return; // 无目标容器则直接返回
59
+ if (!TWIKOO_CONTAINER) return true; // 无目标容器则直接返回true
60
60
 
61
61
  const targetContainer = document.querySelector(TWIKOO_CONTAINER);
62
- if (!targetContainer) return; // 目标容器不存在则返回
62
+ if (!targetContainer) return true; // 目标容器不存在则返回true
63
63
 
64
64
  const commentContainer = document.querySelector(TWIKOO_OPTIONS.el || '#twikoo');
65
65
  if (commentContainer) {
@@ -79,7 +79,7 @@ export default {
79
79
 
80
80
  // 移动成功 或 达到最大重试次数,终止重试
81
81
  if (success || retries >= maxRetries) {
82
- if (!success) console.warn('Twikoo 容器移动失败:未找到 Twikoo 评论容器元素');
82
+ if (!success) console.warn('Twikoo初始化失败:未找到 Twikoo 评论容器元素');
83
83
  return;
84
84
  }
85
85
 
package/index.js CHANGED
@@ -1,9 +1,14 @@
1
1
  const path = require('path')
2
2
 
3
3
  module.exports = (opts, ctx) => {
4
+ const TWIKOO_OPTIONS = {
5
+ // 合并默认值和用户配置,确保 pathPrefix 必为数组
6
+ ...opts.options,
7
+ pathPrefix: Array.isArray(opts.options?.pathPrefix) ? opts.options.pathPrefix : ['/']
8
+ };
4
9
  return {
5
10
  define: {
6
- TWIKOO_OPTIONS: opts.options || { pathPrefix: ['/pages'] },
11
+ TWIKOO_OPTIONS,
7
12
  TWIKOO_CONTAINER: opts.container || 'main.page'
8
13
  },
9
14
  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.9",
3
+ "version": "1.0.11",
4
4
  "description": "Twikoo comment plugin for vuepress 1.x",
5
5
  "main": "index.js",
6
6
  "scripts": {