@sugarat/theme 0.1.46 → 0.1.47

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.
package/node.js CHANGED
@@ -32,7 +32,7 @@ __export(node_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(node_exports);
34
34
 
35
- // ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@1.0.0-rc.13_vue@3.3.4/node_modules/vitepress-plugin-tabs/dist/index.js
35
+ // ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@1.0.0-rc.14_vue@3.3.4/node_modules/vitepress-plugin-tabs/dist/index.js
36
36
  var tabsMarker = "=tabs";
37
37
  var tabsMarkerLen = tabsMarker.length;
38
38
  var ruleBlockTabs = (state, startLine, endLine, silent) => {
@@ -277,11 +277,11 @@ function aliasObjectToArray(obj) {
277
277
  }));
278
278
  }
279
279
  var EXTERNAL_URL_RE = /^[a-z]+:/i;
280
- function joinPath(base, path4) {
281
- return `${base}${path4}`.replace(/\/+/g, "/");
280
+ function joinPath(base, path3) {
281
+ return `${base}${path3}`.replace(/\/+/g, "/");
282
282
  }
283
- function withBase(base, path4) {
284
- return EXTERNAL_URL_RE.test(path4) || path4.startsWith(".") ? path4 : joinPath(base, path4);
283
+ function withBase(base, path3) {
284
+ return EXTERNAL_URL_RE.test(path3) || path3.startsWith(".") ? path3 : joinPath(base, path3);
285
285
  }
286
286
 
287
287
  // src/utils/node/mdPlugins.ts
@@ -450,8 +450,7 @@ function patchVPThemeConfig(cfg, vpThemeConfig = {}) {
450
450
  }
451
451
 
452
452
  // src/utils/node/vitePlugins.ts
453
- var import_path3 = __toESM(require("path"));
454
- var import_child_process2 = require("child_process");
453
+ var import_vitepress_plugin_pagefind = require("vitepress-plugin-pagefind");
455
454
 
456
455
  // src/utils/node/genFeed.ts
457
456
  var import_path2 = __toESM(require("path"));
@@ -532,8 +531,11 @@ function getVitePlugins(cfg) {
532
531
  const plugins = [];
533
532
  const buildEndFn = [];
534
533
  plugins.push(inlineBuildEndPlugin(buildEndFn));
535
- if (cfg?.search === "pagefind" || cfg?.search instanceof Object && cfg.search.mode === "pagefind") {
536
- plugins.push(inlinePagefindPlugin(buildEndFn));
534
+ if (cfg && cfg.search !== false) {
535
+ const ops = cfg.search instanceof Object ? cfg.search : {};
536
+ plugins.push(
537
+ (0, import_vitepress_plugin_pagefind.pagefindPlugin)({ ...ops, customSearchQuery: import_vitepress_plugin_pagefind.chineseSearchOptimize })
538
+ );
537
539
  }
538
540
  buildEndFn.push(genFeed);
539
541
  return plugins;
@@ -543,40 +545,6 @@ function registerVitePlugins(vpCfg, plugins) {
543
545
  plugins
544
546
  };
545
547
  }
546
- function inlinePagefindPlugin(buildEndFn) {
547
- buildEndFn.push(() => {
548
- const ignore = [
549
- "div.aside",
550
- "a.header-anchor"
551
- ];
552
- const { log } = console;
553
- log();
554
- log("=== pagefind: https://pagefind.app/ ===");
555
- const siteDir = import_path3.default.join(
556
- process.argv.slice(2)?.[1] || ".",
557
- ".vitepress/dist"
558
- );
559
- let command = `npx pagefind --site ${siteDir} --output-subdir "_pagefind"`;
560
- if (ignore.length) {
561
- command += ` --exclude-selectors "${ignore.join(", ")}"`;
562
- }
563
- log(command);
564
- log();
565
- (0, import_child_process2.execSync)(command, {
566
- stdio: "inherit"
567
- });
568
- });
569
- return {
570
- name: "@sugarar/theme-plugin-pagefind",
571
- enforce: "pre",
572
- transform(code, id) {
573
- if (id.endsWith("theme-default/Layout.vue")) {
574
- return code.replace("<VPContent>", "<VPContent data-pagefind-body>");
575
- }
576
- return code;
577
- }
578
- };
579
- }
580
548
  function inlineBuildEndPlugin(buildEndFn) {
581
549
  let rewrite = false;
582
550
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.1.46",
3
+ "version": "0.1.47",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -43,6 +43,7 @@
43
43
  "highlight.js": "^11.7.0",
44
44
  "mermaid": "^10.2.4",
45
45
  "vitepress-plugin-mermaid": "^2.0.13",
46
+ "vitepress-plugin-pagefind": "0.2.9",
46
47
  "vue-command-palette": "^0.1.4"
47
48
  },
48
49
  "devDependencies": {
@@ -51,9 +52,10 @@
51
52
  "sass": "^1.56.1",
52
53
  "tsup": " ^6.5.0",
53
54
  "typescript": "^4.8.2",
54
- "vitepress": "1.0.0-rc.13",
55
+ "vitepress": "1.0.0-rc.14",
55
56
  "vitepress-plugin-tabs": "^0.2.0",
56
- "vue": "^3.3.4"
57
+ "vue": "^3.3.4",
58
+ "pagefind": "1.0.3"
57
59
  },
58
60
  "scripts": {
59
61
  "dev": "npm run build:node && npm run dev:docs",
@@ -4,7 +4,7 @@ import BlogHomeInfo from './BlogHomeInfo.vue'
4
4
  import BlogHomeBanner from './BlogHomeBanner.vue'
5
5
  import BlogList from './BlogList.vue'
6
6
  import BlogComment from './BlogComment.vue'
7
- import BlogSearch from './BlogSearch.vue'
7
+ // import BlogSearch from './BlogSearch.vue'
8
8
  import BlogSidebar from './BlogSidebar.vue'
9
9
  import BlogImagePreview from './BlogImagePreview.vue'
10
10
  import BlogArticleAnalyze from './BlogArticleAnalyze.vue'
@@ -34,10 +34,10 @@ const { Layout } = Theme
34
34
  </template>
35
35
 
36
36
  <!-- 自定义搜索,替代Algolia,未来择机移除 -->
37
- <template #nav-bar-content-before>
37
+ <!-- <template #nav-bar-content-before>
38
38
  <slot name="nav-bar-content-before" />
39
39
  <BlogSearch />
40
- </template>
40
+ </template> -->
41
41
  <!-- 自定义首页 -->
42
42
  <template #home-hero-before v-if="isBlogTheme">
43
43
  <slot name="home-hero-before" />
@@ -1,6 +1,10 @@
1
1
  import type { SiteConfig } from 'vitepress'
2
2
  import path from 'path'
3
3
  import { execSync } from 'child_process'
4
+ import {
5
+ pagefindPlugin,
6
+ chineseSearchOptimize
7
+ } from 'vitepress-plugin-pagefind'
4
8
  import type { Theme } from '../../composables/config/index'
5
9
  import { genFeed } from './genFeed'
6
10
 
@@ -13,12 +17,18 @@ export function getVitePlugins(cfg?: Partial<Theme.BlogConfig>) {
13
17
  plugins.push(inlineBuildEndPlugin(buildEndFn))
14
18
 
15
19
  // 内置简化版的pagefind
16
- if (
17
- cfg?.search === 'pagefind' ||
18
- (cfg?.search instanceof Object && cfg.search.mode === 'pagefind')
19
- ) {
20
- plugins.push(inlinePagefindPlugin(buildEndFn))
20
+ if (cfg && cfg.search !== false) {
21
+ const ops = cfg.search instanceof Object ? cfg.search : {}
22
+ plugins.push(
23
+ pagefindPlugin({ ...ops, customSearchQuery: chineseSearchOptimize })
24
+ )
21
25
  }
26
+ // 未来移除使用
27
+ // if (cfg && cfg.search !== undefined) {
28
+ // console.log(
29
+ // '已从内部移除 pagefind 支持,请单独安装 vitepress-plugin-pagefind 插件使用'
30
+ // )
31
+ // }
22
32
 
23
33
  buildEndFn.push(genFeed)
24
34
  return plugins