valaxy 0.19.1 → 0.19.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/client/App.vue CHANGED
@@ -93,5 +93,9 @@ useSchemaOrg([
93
93
  <ValaxyThemeApp />
94
94
  <ValaxyAddons />
95
95
  <ValaxyUserApp />
96
- <RouterView />
96
+ <router-view v-slot="{ Component, route }">
97
+ <transition name="app-transition">
98
+ <component :is="Component" :key="route" />
99
+ </transition>
100
+ </router-view>
97
101
  </template>
@@ -13,6 +13,13 @@ export interface BaseCategory {
13
13
  total: number
14
14
  }
15
15
 
16
+ /**
17
+ * @en
18
+ * Category list
19
+ *
20
+ * @zh
21
+ * 分类列表
22
+ */
16
23
  export interface CategoryList {
17
24
  /**
18
25
  * category name
@@ -27,7 +34,11 @@ export interface CategoryList {
27
34
  export type Category = CategoryList
28
35
  export type Categories = Map<string, Post | CategoryList>
29
36
 
30
- // todo write unit test
37
+ /**
38
+ * For theme development, you can use this function to determine whether the category is a category list.
39
+ * @todo write unit test
40
+ * @param category
41
+ */
31
42
  export function isCategoryList(category: any): category is CategoryList {
32
43
  return category.children
33
44
  }
@@ -3,6 +3,13 @@ import type { DefaultTheme, Header } from 'valaxy/types'
3
3
  import { onContentUpdated } from '../../utils'
4
4
  import { useFrontmatter, useThemeConfig } from '../..'
5
5
 
6
+ /**
7
+ * @en
8
+ * Menu item, the title menu parsed from the article.
9
+ *
10
+ * @zh
11
+ * 菜单项,从文章中解析出的标题菜单。
12
+ */
6
13
  export type MenuItem = Omit<Header, 'slug' | 'children'> & {
7
14
  children?: MenuItem[]
8
15
  }
@@ -105,7 +112,11 @@ export function useOutline() {
105
112
  * get headers from document directly
106
113
  */
107
114
  export function getHeaders(range: Exclude<DefaultTheme.Config['outline'], false>) {
108
- const headers = Array.from(document.querySelectorAll('.markdown-body :where(h1,h2,h3,h4,h5,h6)'))
115
+ // when transition, the markdown-body will be two
116
+ // the first is the old one, the last is the new one
117
+ const markdownBodyElements = document.querySelectorAll('.markdown-body') as NodeListOf<HTMLElement>
118
+ const markdownBody = markdownBodyElements[markdownBodyElements.length - 1]
119
+ const headers = Array.from(markdownBody.querySelectorAll('.markdown-body :where(h1,h2,h3,h4,h5,h6)'))
109
120
  .filter(el => el.id && el.hasChildNodes())
110
121
  .map((el) => {
111
122
  const level = Number(el.tagName[1])
@@ -2,6 +2,15 @@ import { computed } from 'vue'
2
2
  import type { Post } from '../../types'
3
3
  import { useSiteStore } from '../stores'
4
4
 
5
+ /**
6
+ * @en
7
+ * Tag list, key is tag name, value is the object of tag.
8
+ * - count: the number of posts with this tag.
9
+ *
10
+ * @zh
11
+ * 标签列表,键是标签名,值是标签对象。
12
+ * - count: 使用该标签的文章数量。
13
+ */
5
14
  export type Tags = Map<string, {
6
15
  count: number
7
16
  }>
@@ -35,8 +35,8 @@ sidebar:
35
35
 
36
36
  post:
37
37
  decrypt: DECRYPT
38
- posted: Posted on
39
- edited: Edited on
38
+ posted: 'Posted on '
39
+ edited: 'Edited on '
40
40
  created: Created
41
41
  modified: Modified
42
42
  edit: Edit this post
@@ -3,6 +3,13 @@
3
3
  import { defineMermaidSetup } from 'valaxy'
4
4
  import type { MermaidOptions } from '../types'
5
5
 
6
+ /**
7
+ * @en
8
+ * Extend the Mermaid configuration.
9
+ *
10
+ * @zh
11
+ * 扩展 Mermaid 配置。
12
+ */
6
13
  export default defineMermaidSetup(() => {
7
14
  // eslint-disable-next-line prefer-const
8
15
  let injection_return: MermaidOptions = {
package/client/setups.ts CHANGED
@@ -2,6 +2,14 @@ import type { ViteSSGContext } from 'vite-ssg'
2
2
  import type { Awaitable } from '@antfu/utils'
3
3
  import type { MermaidOptions } from './types'
4
4
 
5
+ /**
6
+ * @see https://github.com/antfu-collective/vite-ssg
7
+ * @en
8
+ * The context object for the application setup function.
9
+ *
10
+ * @zh
11
+ * 应用 setup 函数的上下文对象。(包括了 ViteSSG context)
12
+ */
5
13
  export type AppContext = ViteSSGContext
6
14
 
7
15
  export type AppSetup = (ctx: AppContext) => Awaitable<void>
@@ -9,6 +17,13 @@ export type AppSetup = (ctx: AppContext) => Awaitable<void>
9
17
  // client
10
18
  export type MermaidSetup = () => Partial<MermaidOptions> | void
11
19
 
20
+ /**
21
+ * @en
22
+ * Define the setup function for the client application.
23
+ *
24
+ * @zh
25
+ * 扩展客户端应用的 setup 函数。
26
+ */
12
27
  export function defineAppSetup(fn: AppSetup) {
13
28
  return fn
14
29
  }
@@ -3,4 +3,7 @@ import type mermaid from 'mermaid'
3
3
 
4
4
  export type UserModule = (ctx: ViteSSGContext) => void
5
5
 
6
+ /**
7
+ * @see https://mermaid.js.org/config/schema-docs/config.html#mermaid-config-schema
8
+ */
6
9
  export type MermaidOptions = (typeof mermaid.initialize) extends (a: infer A) => any ? A : never
@@ -1,7 +1,18 @@
1
1
  import type { Router } from 'vue-router'
2
2
 
3
+ /**
4
+ * @en
5
+ * Options for scrolling to a target element.
6
+ *
7
+ * @zh
8
+ * 滚动到目标元素的选项。
9
+ */
3
10
  export interface ScrollToOptions {
4
11
  /**
12
+ * @en
13
+ * Whether to scroll smoothly.
14
+ *
15
+ * @zh
5
16
  * 平滑滚动
6
17
  */
7
18
  smooth: boolean
@@ -11,6 +22,13 @@ export interface ScrollToOptions {
11
22
  targetPadding: number
12
23
  }
13
24
 
25
+ /**
26
+ * For theme developers, you can use this function to scroll to the target element.
27
+ * For example, when you click the anchor link in the markdown file, it will scroll to the target element.
28
+ * @param el
29
+ * @param hash
30
+ * @param options
31
+ */
14
32
  export function scrollTo(el: HTMLElement, hash: string, options: Partial<ScrollToOptions> = {
15
33
  smooth: true,
16
34
  targetPadding: -64,
@@ -10,6 +10,14 @@ export function formatDate(date: string | number | Date, template = 'yyyy-MM-dd'
10
10
  return format(date, template)
11
11
  }
12
12
 
13
+ /**
14
+ * date-fns format date with 'yyyy-MM-dd HH:mm:ss'
15
+ * @param date
16
+ */
17
+ export function formatTimestamp(date: string | number | Date): string {
18
+ return format(date, 'yyyy-MM-dd HH:mm:ss')
19
+ }
20
+
13
21
  /**
14
22
  * sort posts by date
15
23
  * @param posts