@sugarat/theme 0.5.12 → 0.5.14

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.d.ts CHANGED
@@ -4,6 +4,7 @@ import { Repo, Mapping } from '@giscus/vue';
4
4
  import { Options } from 'oh-my-live2d';
5
5
  import { PagefindConfig } from 'vitepress-plugin-pagefind';
6
6
  import { AnnouncementOptions } from 'vitepress-plugin-announcement';
7
+ import { ImagePreviewOptions } from 'vitepress-plugin-image-preview';
7
8
 
8
9
  type RSSPluginOptions = RSSOptions;
9
10
  type ThemeableImage = string | {
@@ -392,6 +393,10 @@ declare namespace Theme {
392
393
  */
393
394
  alert?: Alert;
394
395
  popover?: AnnouncementOptions;
396
+ /**
397
+ * 图片预览插件配置
398
+ */
399
+ imagePreview?: ImagePreviewOptions;
395
400
  friend?: FriendLink[] | FriendConfig;
396
401
  authorList?: Omit<FriendLink, 'avatar'>[];
397
402
  /**
package/node.js CHANGED
@@ -487,6 +487,7 @@ var import_vitepress_plugin_rss = require("vitepress-plugin-rss");
487
487
  var import_theme_shared4 = require("@sugarat/theme-shared");
488
488
  var import_vitepress_plugin_announcement = require("vitepress-plugin-announcement");
489
489
  var import_vitepress_plugin_group_icons2 = require("vitepress-plugin-group-icons");
490
+ var import_vitepress_plugin_image_preview = require("vitepress-plugin-image-preview");
490
491
 
491
492
  // src/utils/node/hot-reload-plugin.ts
492
493
  var import_fs = __toESM(require("fs"));
@@ -496,7 +497,7 @@ function themeReloadPlugin() {
496
497
  let vitepressConfig;
497
498
  let docsDir;
498
499
  const generateRoute = (filepath) => {
499
- return filepath.replace(docsDir, "").replace(".md", "");
500
+ return (0, import_theme_shared3.normalizePath)(filepath).replace(docsDir, "").replace(".md", "");
500
501
  };
501
502
  return {
502
503
  name: "@sugarat/theme-reload",
@@ -569,6 +570,7 @@ function themeReloadPlugin() {
569
570
  function getVitePlugins(cfg = {}) {
570
571
  const plugins = [];
571
572
  plugins.push(cacheAllGitTimestampsPlugin());
573
+ plugins.push((0, import_vitepress_plugin_image_preview.ImagePreviewPlugin)(cfg?.imagePreview));
572
574
  if (cfg.themeColor) {
573
575
  plugins.push(setThemeScript(cfg.themeColor));
574
576
  }
package/node.mjs CHANGED
@@ -456,16 +456,17 @@ import { RssPlugin } from "vitepress-plugin-rss";
456
456
  import { cacheAllGitTimestamps, joinPath as joinPath2 } from "@sugarat/theme-shared";
457
457
  import { AnnouncementPlugin } from "vitepress-plugin-announcement";
458
458
  import { groupIconVitePlugin } from "vitepress-plugin-group-icons";
459
+ import { ImagePreviewPlugin } from "vitepress-plugin-image-preview";
459
460
 
460
461
  // src/utils/node/hot-reload-plugin.ts
461
462
  import fs2 from "fs";
462
- import { grayMatter as grayMatter2 } from "@sugarat/theme-shared";
463
+ import { grayMatter as grayMatter2, normalizePath as normalizePath3 } from "@sugarat/theme-shared";
463
464
  function themeReloadPlugin() {
464
465
  let blogConfig;
465
466
  let vitepressConfig;
466
467
  let docsDir;
467
468
  const generateRoute = (filepath) => {
468
- return filepath.replace(docsDir, "").replace(".md", "");
469
+ return normalizePath3(filepath).replace(docsDir, "").replace(".md", "");
469
470
  };
470
471
  return {
471
472
  name: "@sugarat/theme-reload",
@@ -538,6 +539,7 @@ function themeReloadPlugin() {
538
539
  function getVitePlugins(cfg = {}) {
539
540
  const plugins = [];
540
541
  plugins.push(cacheAllGitTimestampsPlugin());
542
+ plugins.push(ImagePreviewPlugin(cfg?.imagePreview));
541
543
  if (cfg.themeColor) {
542
544
  plugins.push(setThemeScript(cfg.themeColor));
543
545
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.5.12",
3
+ "version": "0.5.14",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "author": "sugar",
6
6
  "license": "MIT",
@@ -51,10 +51,11 @@
51
51
  "vitepress-plugin-group-icons": "1.6.5",
52
52
  "vitepress-plugin-mermaid": "2.0.13",
53
53
  "vitepress-plugin-tabs": "0.7.3",
54
- "@sugarat/theme-shared": "0.0.7",
55
54
  "vitepress-plugin-announcement": "0.1.7",
56
- "vitepress-plugin-pagefind": "0.4.18",
57
- "vitepress-plugin-rss": "0.4.2"
55
+ "@sugarat/theme-shared": "0.0.7",
56
+ "vitepress-plugin-image-preview": "0.1.0",
57
+ "vitepress-plugin-rss": "0.4.2",
58
+ "vitepress-plugin-pagefind": "0.4.18"
58
59
  },
59
60
  "devDependencies": {
60
61
  "artalk": "^2.8.5",
@@ -8,7 +8,7 @@ import BlogHomeInfo from './BlogHomeInfo.vue'
8
8
  import BlogHomeBanner from './BlogHomeBanner.vue'
9
9
  import BlogList from './BlogList.vue'
10
10
  import BlogSidebar from './BlogSidebar.vue'
11
- import BlogImagePreview from './BlogImagePreview.vue'
11
+
12
12
  import BlogArticleAnalyze from './BlogArticleAnalyze.vue'
13
13
  import BlogAlert from './BlogAlert.vue'
14
14
  import BlogFooter from './BlogFooter.vue'
@@ -49,8 +49,6 @@ const openTransition = useDarkTransitionConfig()
49
49
  <!-- 阅读时间分析 -->
50
50
  <ClientOnly>
51
51
  <BlogArticleAnalyze />
52
- <!-- 图片预览 -->
53
- <BlogImagePreview />
54
52
  </ClientOnly>
55
53
  </template>
56
54
 
@@ -128,10 +126,6 @@ const openTransition = useDarkTransitionConfig()
128
126
  <!-- content -->
129
127
  <template #page-top>
130
128
  <slot name="page-top" />
131
- <ClientOnly>
132
- <!-- 图片预览 -->
133
- <BlogImagePreview />
134
- </ClientOnly>
135
129
  </template>
136
130
  <template #page-bottom>
137
131
  <slot name="page-bottom" />
@@ -5,6 +5,7 @@ import type { Mapping, Repo } from '@giscus/vue'
5
5
  import type { Options as Oml2dOptions } from 'oh-my-live2d'
6
6
  import type { PagefindConfig } from 'vitepress-plugin-pagefind'
7
7
  import type { AnnouncementOptions } from 'vitepress-plugin-announcement'
8
+ import type { ImagePreviewOptions } from 'vitepress-plugin-image-preview'
8
9
 
9
10
  type RSSPluginOptions = RSSOptions
10
11
 
@@ -420,6 +421,10 @@ export namespace Theme {
420
421
  */
421
422
  alert?: Alert
422
423
  popover?: AnnouncementOptions
424
+ /**
425
+ * 图片预览插件配置
426
+ */
427
+ imagePreview?: ImagePreviewOptions
423
428
  friend?: FriendLink[] | FriendConfig
424
429
  authorList?: Omit<FriendLink, 'avatar'>[]
425
430
  /**
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs'
2
2
  import type { PluginOption } from 'vite'
3
3
  import type { SiteConfig } from 'vitepress'
4
- import { grayMatter } from '@sugarat/theme-shared'
4
+ import { grayMatter, normalizePath } from '@sugarat/theme-shared'
5
5
  import type { Theme } from '../../composables/config/index'
6
6
  import { getArticleMeta } from './theme'
7
7
  import { debounce, isEqual } from './index'
@@ -12,7 +12,7 @@ export function themeReloadPlugin() {
12
12
  let docsDir: string
13
13
 
14
14
  const generateRoute = (filepath: string) => {
15
- return filepath.replace(docsDir, '').replace('.md', '')
15
+ return normalizePath(filepath).replace(docsDir, '').replace('.md', '')
16
16
  }
17
17
 
18
18
  return {
@@ -7,6 +7,7 @@ import type { PluginOption } from 'vite'
7
7
  import { cacheAllGitTimestamps, joinPath } from '@sugarat/theme-shared'
8
8
  import { AnnouncementPlugin } from 'vitepress-plugin-announcement'
9
9
  import { groupIconVitePlugin } from 'vitepress-plugin-group-icons'
10
+ import { ImagePreviewPlugin } from 'vitepress-plugin-image-preview'
10
11
  import type { Theme } from '../../composables/config/index'
11
12
  import { _require } from './mdPlugins'
12
13
  import { themeReloadPlugin } from './hot-reload-plugin'
@@ -18,6 +19,9 @@ export function getVitePlugins(cfg: Partial<Theme.BlogConfig> = {}) {
18
19
  // 缓存所有文章的 git 提交时间
19
20
  plugins.push(cacheAllGitTimestampsPlugin())
20
21
 
22
+ // 图片预览
23
+ plugins.push(ImagePreviewPlugin(cfg?.imagePreview))
24
+
21
25
  // 处理自定义主题色
22
26
  if (cfg.themeColor) {
23
27
  plugins.push(setThemeScript(cfg.themeColor))