@sugarat/theme 0.4.0 → 0.4.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.
package/node.d.ts CHANGED
@@ -175,6 +175,11 @@ declare namespace Theme {
175
175
  */
176
176
  style?: 'card' | 'sidebar';
177
177
  }
178
+ interface HomeAnalysis {
179
+ articles?: {
180
+ title?: string[];
181
+ };
182
+ }
178
183
  interface HomeBlog {
179
184
  name?: string;
180
185
  motto?: string;
@@ -187,6 +192,10 @@ declare namespace Theme {
187
192
  * @default 'card'
188
193
  */
189
194
  avatarMode?: 'card' | 'split';
195
+ /**
196
+ * 首页数据分析卡片
197
+ */
198
+ analysis?: HomeAnalysis;
190
199
  }
191
200
  interface ArticleConfig {
192
201
  readingTime?: boolean;
package/node.js CHANGED
@@ -764,6 +764,7 @@ function providePageData(cfg) {
764
764
  // src/node.ts
765
765
  function getThemeConfig(cfg = {}) {
766
766
  checkConfig(cfg);
767
+ cfg.mermaid = cfg.mermaid ?? false;
767
768
  const pagesData = [];
768
769
  const extraVPConfig = {
769
770
  vite: {}
@@ -772,7 +773,6 @@ function getThemeConfig(cfg = {}) {
772
773
  registerVitePlugins(extraVPConfig, vitePlugins);
773
774
  const markdownPlugin = getMarkdownPlugins(cfg);
774
775
  registerMdPlugins(extraVPConfig, markdownPlugin);
775
- cfg.mermaid = cfg.mermaid ?? false;
776
776
  if (cfg?.mermaid !== false) {
777
777
  patchMermaidPluginCfg(extraVPConfig);
778
778
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "author": "sugar",
6
6
  "license": "MIT",
@@ -2,7 +2,7 @@
2
2
  import { computed } from 'vue'
3
3
  import { useData } from 'vitepress'
4
4
  import { isCurrentWeek } from '../utils/client'
5
- import { useArticles, useBlogConfig } from '../composables/config/blog'
5
+ import { useArticles, useBlogConfig, useHomeAnalysis } from '../composables/config/blog'
6
6
  import BlogAuthor from './BlogAuthor.vue'
7
7
 
8
8
  const { home } = useBlogConfig()
@@ -31,6 +31,9 @@ const currentWeek = computed(() => {
31
31
  return isCurrentWeek(pubDate)
32
32
  })
33
33
  })
34
+
35
+ const analysis = useHomeAnalysis()
36
+ const titles = computed(() => (frontmatter.value?.blog?.analysis?.articles?.title || analysis?.articles?.title || []))
34
37
  </script>
35
38
 
36
39
  <template>
@@ -41,17 +44,17 @@ const currentWeek = computed(() => {
41
44
  <div class="overview-data">
42
45
  <div class="overview-item">
43
46
  <span class="count">{{ notHiddenArticles.length }}</span>
44
- <span class="label">博客文章</span>
47
+ <span class="label">{{ titles[0] || '博客文章' }}</span>
45
48
  </div>
46
49
  <div class="split" />
47
50
  <div class="overview-item">
48
51
  <span class="count">+{{ currentMonth?.length }}</span>
49
- <span class="label">本月更新</span>
52
+ <span class="label">{{ titles[1] || '本月更新' }}</span>
50
53
  </div>
51
54
  <div class="split" />
52
55
  <div class="overview-item">
53
56
  <span class="count">+{{ currentWeek?.length }}</span>
54
- <span class="label">本周更新</span>
57
+ <span class="label">{{ titles[2] || '本周更新' }}</span>
55
58
  </div>
56
59
  </div>
57
60
  </div>
@@ -233,3 +233,7 @@ export function useCleanUrls() {
233
233
  export function useImageStyle() {
234
234
  return inject(configSymbol)?.value?.blog?.imageStyle || {} as Theme.ImageStyleConfig
235
235
  }
236
+
237
+ export function useHomeAnalysis() {
238
+ return inject(configSymbol)?.value?.blog?.home?.analysis
239
+ }
@@ -185,6 +185,12 @@ export namespace Theme {
185
185
  style?: 'card' | 'sidebar'
186
186
  }
187
187
 
188
+ export interface HomeAnalysis {
189
+ articles?: {
190
+ title?: string[]
191
+ }
192
+ }
193
+
188
194
  export interface HomeBlog {
189
195
  name?: string
190
196
  motto?: string
@@ -197,6 +203,10 @@ export namespace Theme {
197
203
  * @default 'card'
198
204
  */
199
205
  avatarMode?: 'card' | 'split'
206
+ /**
207
+ * 首页数据分析卡片
208
+ */
209
+ analysis?: HomeAnalysis
200
210
  }
201
211
 
202
212
  export interface ArticleConfig {
package/src/node.ts CHANGED
@@ -17,6 +17,9 @@ export function getThemeConfig(cfg: Partial<Theme.BlogConfig> = {}) {
17
17
  // 配置校验
18
18
  checkConfig(cfg)
19
19
 
20
+ // 默认不开启 markdown 图表,会明显影响构建速度
21
+ cfg.mermaid = cfg.mermaid ?? false
22
+
20
23
  // 文章数据
21
24
  const pagesData: Theme.PageData[] = []
22
25
  const extraVPConfig: any = {
@@ -34,8 +37,6 @@ export function getThemeConfig(cfg: Partial<Theme.BlogConfig> = {}) {
34
37
  registerMdPlugins(extraVPConfig, markdownPlugin)
35
38
 
36
39
  // patch extraVPConfig
37
- // 默认不开启 markdown 图表,会明显影响构建速度
38
- cfg.mermaid = cfg.mermaid ?? false
39
40
  if (cfg?.mermaid !== false) {
40
41
  patchMermaidPluginCfg(extraVPConfig)
41
42
  }