@sugarat/theme 0.4.10 → 0.4.12

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,16 @@ declare namespace Theme {
175
175
  * @default 'sidebar'
176
176
  */
177
177
  style?: 'card' | 'sidebar';
178
+ /**
179
+ * 是否在左侧显示日期
180
+ * @default true
181
+ */
182
+ showDate?: boolean;
183
+ /**
184
+ * 是否在左侧展示序号
185
+ * @default true
186
+ */
187
+ showNum?: boolean;
178
188
  }
179
189
  interface HomeAnalysis {
180
190
  articles?: {
@@ -516,7 +526,7 @@ declare namespace Theme {
516
526
  * 周前
517
527
  */
518
528
  weeksAgo?: string;
519
- } | ((date: Date) => string);
529
+ } | ((date: Date | string) => string);
520
530
  interface BackToTop {
521
531
  /**
522
532
  * 距离顶部多少距离出现
package/node.js CHANGED
@@ -40,7 +40,7 @@ module.exports = __toCommonJS(node_exports);
40
40
  // src/utils/node/mdPlugins.ts
41
41
  var import_module = require("module");
42
42
 
43
- // ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@1.3.2_@algolia+client-search@4.19.1_@types+node@20.6.3__i342z2vy4vtzoo4ecdc3cz7rya/node_modules/vitepress-plugin-tabs/dist/index.js
43
+ // ../../node_modules/.pnpm/vitepress-plugin-tabs@0.2.0_vitepress@1.3.4_@algolia+client-search@4.19.1_@types+node@20.6.3__ovjzvjgjmyeesvgttjdmi2b3dm/node_modules/vitepress-plugin-tabs/dist/index.js
44
44
  var tabsMarker = "=tabs";
45
45
  var tabsMarkerLen = tabsMarker.length;
46
46
  var ruleBlockTabs = (state, startLine, endLine, silent) => {
@@ -398,7 +398,8 @@ async function getArticleMeta(filepath, route, timeZone = defaultTimeZoneOffset)
398
398
  if (!meta.title) {
399
399
  meta.title = (0, import_theme_shared2.getDefaultTitle)(content);
400
400
  }
401
- const date = await (meta.date && /* @__PURE__ */ new Date(`${new Date(meta.date).toUTCString()}+${timeZone}`) || (0, import_theme_shared2.getFileLastModifyTime)(filepath));
401
+ const utcValue = timeZone >= 0 ? `+${timeZone}` : `${timeZone}`;
402
+ const date = await (meta.date && /* @__PURE__ */ new Date(`${new Date(meta.date).toUTCString()}${utcValue}`) || (0, import_theme_shared2.getFileLastModifyTime)(filepath));
402
403
  meta.date = formatDate(date || /* @__PURE__ */ new Date());
403
404
  meta.categories = typeof meta.categories === "string" ? [meta.categories] : meta.categories;
404
405
  meta.tags = typeof meta.tags === "string" ? [meta.tags] : meta.tags;
@@ -444,8 +445,8 @@ function patchVPConfig(vpConfig, cfg) {
444
445
  if (cfg?.comment && "type" in cfg.comment && cfg?.comment?.type === "artalk") {
445
446
  const server = cfg.comment?.options?.server;
446
447
  if (server) {
447
- vpConfig.head.push(["link", { href: `${server}/dist/Artalk.css`, rel: "stylesheet" }]);
448
- vpConfig.head.push(["script", { src: `${server}/dist/Artalk.js`, id: "artalk-script" }]);
448
+ vpConfig.head.push(["link", { href: `${server} /dist/Artalk.css`, rel: "stylesheet" }]);
449
+ vpConfig.head.push(["script", { src: `${server} /dist/Artalk.js`, id: "artalk-script" }]);
449
450
  }
450
451
  }
451
452
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarat/theme",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "简约风的 Vitepress 博客主题,sugarat vitepress blog theme",
5
5
  "author": "sugar",
6
6
  "license": "MIT",
@@ -62,8 +62,9 @@
62
62
  "sass": "^1.77.8",
63
63
  "typescript": "^5.4.5",
64
64
  "vite": "^5.2.11",
65
- "vitepress": "1.3.2",
66
- "vue": "^3.4.26"
65
+ "vitepress": "1.3.4",
66
+ "vue": "^3.4.26",
67
+ "vitepress-plugin-51la": "0.1.0"
67
68
  },
68
69
  "scripts": {
69
70
  "dev": "npm run build:node && npm run dev:docs",
@@ -82,7 +82,7 @@ const resultCover = computed(() => {
82
82
  <div class="info-part">
83
83
  <!-- 标题 -->
84
84
  <p class="title pc-visible">
85
- {{ title }}
85
+ <span>{{ title }}</span>
86
86
  </p>
87
87
  <!-- 简短描述 -->
88
88
  <p v-show="!descriptionHTML && !!description" class="description">
@@ -21,6 +21,10 @@ const recommendPadding = computed(() =>
21
21
  const recommend = computed(() =>
22
22
  _recommend === false ? undefined : _recommend
23
23
  )
24
+
25
+ const showDate = computed(() => (_recommend && _recommend?.showDate) ?? true)
26
+ const showNum = computed(() => (_recommend && _recommend?.showNum) ?? true)
27
+
24
28
  const title = computed(() => recommend.value?.title ?? (`<span class="svg-icon">${recommendSVG}</span>` + '相关文章'))
25
29
  const pageSize = computed(() => recommend.value?.pageSize || 9)
26
30
  const nextText = computed(() => recommend.value?.nextText || '换一组')
@@ -169,10 +173,16 @@ function handleLinkClick(link: string) {
169
173
  </ElButton>
170
174
  </div>
171
175
  <!-- 文章列表 -->
172
- <ol v-if="currentWikiData.length" class="recommend-container">
173
- <li v-for="(v, idx) in currentWikiData" :key="v.route">
176
+ <ol
177
+ v-if="currentWikiData.length" :class="{
178
+ 'hide-num': !showNum,
179
+ }" class="recommend-container"
180
+ >
181
+ <li
182
+ v-for="(v, idx) in currentWikiData" :key="v.route"
183
+ >
174
184
  <!-- 序号 -->
175
- <i class="num">{{ startIdx + idx + 1 }}</i>
185
+ <i v-if="showNum" class="num">{{ startIdx + idx + 1 }}</i>
176
186
  <!-- 简介 -->
177
187
  <div class="des">
178
188
  <!-- title -->
@@ -189,7 +199,7 @@ function handleLinkClick(link: string) {
189
199
  <span>{{ v.meta.title }}</span>
190
200
  </a>
191
201
  <!-- 描述信息 -->
192
- <div class="suffix">
202
+ <div v-if="showDate" class="suffix">
193
203
  <!-- 日期 -->
194
204
  <span class="tag">{{ formatShowDate(v.meta.date) }}</span>
195
205
  </div>
@@ -234,6 +244,9 @@ function handleLinkClick(link: string) {
234
244
  padding: 0 10px 0 0px;
235
245
  width: 100%;
236
246
 
247
+ &.hide-num>li{
248
+ padding: 5px 0;
249
+ }
237
250
  li {
238
251
  display: flex;
239
252
 
@@ -253,6 +266,9 @@ function handleLinkClick(link: string) {
253
266
  overflow: hidden;
254
267
  text-overflow: ellipsis;
255
268
  white-space: nowrap;
269
+ display: flex;
270
+ flex-direction: column;
271
+ justify-content: center;
256
272
  }
257
273
 
258
274
  .title {
@@ -263,21 +279,21 @@ function handleLinkClick(link: string) {
263
279
  font-weight: 500;
264
280
  position: relative;
265
281
  cursor: pointer;
266
-
267
- &.current {
282
+ transition: color .25s;
283
+ &.current,&:hover {
268
284
  color: var(--vp-c-brand-1);
269
285
  }
270
286
  }
271
287
 
272
- .title:hover::after {
273
- content: "";
274
- position: absolute;
275
- left: 0;
276
- right: 0;
277
- height: 0;
278
- bottom: -3px;
279
- border-bottom: 1px solid #b1b3b8;
280
- }
288
+ // .title:hover::after {
289
+ // content: "";
290
+ // position: absolute;
291
+ // left: 0;
292
+ // right: 0;
293
+ // height: 0;
294
+ // bottom: -3px;
295
+ // border-bottom: 1px solid #b1b3b8;
296
+ // }
281
297
 
282
298
  .suffix {
283
299
  font-size: 12px;
@@ -184,6 +184,16 @@ export namespace Theme {
184
184
  * @default 'sidebar'
185
185
  */
186
186
  style?: 'card' | 'sidebar'
187
+ /**
188
+ * 是否在左侧显示日期
189
+ * @default true
190
+ */
191
+ showDate?: boolean
192
+ /**
193
+ * 是否在左侧展示序号
194
+ * @default true
195
+ */
196
+ showNum?: boolean
187
197
  }
188
198
 
189
199
  export interface HomeAnalysis {
@@ -552,7 +562,7 @@ export namespace Theme {
552
562
  * 周前
553
563
  */
554
564
  weeksAgo?: string
555
- } | ((date: Date) => string)
565
+ } | ((date: Date | string) => string)
556
566
  export interface BackToTop {
557
567
  /**
558
568
  * 距离顶部多少距离出现
@@ -43,17 +43,18 @@ export async function getArticleMeta(filepath: string, route: string, timeZone =
43
43
  if (!meta.title) {
44
44
  meta.title = getDefaultTitle(content)
45
45
  }
46
+ const utcValue = timeZone >= 0 ? `+${timeZone}` : `${timeZone}`
46
47
  const date = await (
47
48
  (meta.date
48
- && new Date(`${new Date(meta.date).toUTCString()}+${timeZone}`))
49
- || getFileLastModifyTime(filepath)
49
+ && new Date(`${new Date(meta.date).toUTCString()}${utcValue}`))
50
+ || getFileLastModifyTime(filepath)
50
51
  )
51
52
  // 无法获取时兜底当前时间
52
53
  meta.date = formatDate(date || new Date())
53
54
 
54
55
  // 处理tags和categories,兼容历史文章
55
56
  meta.categories
56
- = typeof meta.categories === 'string'
57
+ = typeof meta.categories === 'string'
57
58
  ? [meta.categories]
58
59
  : meta.categories
59
60
  meta.tags = typeof meta.tags === 'string' ? [meta.tags] : meta.tags
@@ -66,12 +67,12 @@ export async function getArticleMeta(filepath: string, route: string, timeZone =
66
67
  // 获取摘要信息
67
68
  // TODO:摘要生成优化
68
69
  meta.description
69
- = meta.description || getTextSummary(content, 100) || excerpt
70
+ = meta.description || getTextSummary(content, 100) || excerpt
70
71
 
71
72
  // 获取封面图
72
73
  meta.cover
73
- = meta.cover
74
- ?? (getFirstImagURLFromMD(fileContent, route))
74
+ = meta.cover
75
+ ?? (getFirstImagURLFromMD(fileContent, route))
75
76
 
76
77
  // 是否发布 默认发布
77
78
  if (meta.publish === false) {
@@ -82,9 +83,9 @@ export async function getArticleMeta(filepath: string, route: string, timeZone =
82
83
  }
83
84
  export async function getArticles(cfg: Partial<Theme.BlogConfig>, vpConfig: SiteConfig) {
84
85
  const srcDir
85
- = cfg?.srcDir || vpConfig.srcDir.replace(vpConfig.root, '').replace(/^\//, '')
86
- || process.argv.slice(2)?.[1]
87
- || '.'
86
+ = cfg?.srcDir || vpConfig.srcDir.replace(vpConfig.root, '').replace(/^\//, '')
87
+ || process.argv.slice(2)?.[1]
88
+ || '.'
88
89
  const files = glob.sync(`${srcDir}/**/*.md`, { ignore: ['node_modules'], absolute: true })
89
90
 
90
91
  const metaResults = files.reduce((prev, curr) => {
@@ -124,8 +125,8 @@ export function patchVPConfig(vpConfig: any, cfg?: Partial<Theme.BlogConfig>) {
124
125
  if (cfg?.comment && 'type' in cfg.comment && cfg?.comment?.type === 'artalk') {
125
126
  const server = cfg.comment?.options?.server
126
127
  if (server) {
127
- vpConfig.head.push(['link', { href: `${server}/dist/Artalk.css`, rel: 'stylesheet' }])
128
- vpConfig.head.push(['script', { src: `${server}/dist/Artalk.js`, id: 'artalk-script' }])
128
+ vpConfig.head.push(['link', { href: `${server} /dist/Artalk.css`, rel: 'stylesheet' }])
129
+ vpConfig.head.push(['script', { src: `${server} /dist/Artalk.js`, id: 'artalk-script' }])
129
130
  }
130
131
  }
131
132
  }