valaxy 0.26.6 → 0.26.8

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.
@@ -2,10 +2,12 @@
2
2
  import { runContentUpdated, useDecrypt, useFrontmatter } from 'valaxy'
3
3
  import { computed, defineComponent, h, ref } from 'vue'
4
4
 
5
- const props = defineProps<{
5
+ const props = withDefaults(defineProps<{
6
6
  encryptedContent: string
7
7
  hint?: string
8
- }>()
8
+ }>(), {
9
+ hint: '',
10
+ })
9
11
 
10
12
  const password = ref('')
11
13
  const decryptedContent = ref('')
@@ -1,4 +1,4 @@
1
- import type { MaybeRef } from '@vueuse/core'
1
+ import type { MaybeRef } from 'vue'
2
2
  import type { Post } from '../../types'
3
3
  import { computed, unref } from 'vue'
4
4
  import { useSiteStore } from '../stores'
@@ -1,9 +1,10 @@
1
1
  import type { Post } from 'valaxy'
2
2
  import type { ComputedRef } from 'vue'
3
+ import { orderByMeta, useSiteConfig } from 'valaxy'
3
4
  import { computed } from 'vue'
4
5
  import { useI18n } from 'vue-i18n'
5
6
  import { useRouterStore } from '../../stores'
6
- import { sortByDate, tObject } from '../../utils'
7
+ import { tObject } from '../../utils'
7
8
 
8
9
  export * from './usePagination'
9
10
  export * from './usePrevNext'
@@ -43,6 +44,7 @@ export function usePageList() {
43
44
  export function usePostList(params: {
44
45
  type?: string
45
46
  } = {}) {
47
+ const siteConfig = useSiteConfig()
46
48
  const pageList = usePageList()
47
49
  return computed(() => {
48
50
  const routes = pageList.value
@@ -54,11 +56,16 @@ export function usePostList(params: {
54
56
  && (!i.hide || i.hide === 'index'), // hide `hide: all` posts
55
57
  )
56
58
 
59
+ function sortBySiteConfigOrderBy(posts: Post[]) {
60
+ const orderBy = siteConfig.value.orderBy
61
+ return orderByMeta(posts, orderBy)
62
+ }
63
+
57
64
  /**
58
65
  * 置顶
59
66
  */
60
- const topPosts = sortByDate(routes.filter(i => i.top)).sort((a, b) => b.top! - a.top!)
61
- const otherPosts = sortByDate(routes.filter(i => !i.top))
67
+ const topPosts = sortBySiteConfigOrderBy(routes.filter(i => i.top)).sort((a, b) => b.top! - a.top!)
68
+ const otherPosts = sortBySiteConfigOrderBy(routes.filter(i => !i.top))
62
69
 
63
70
  return topPosts.concat(otherPosts)
64
71
  })
@@ -1,5 +1,5 @@
1
1
  import type { UseFuseOptions } from '@vueuse/integrations/useFuse'
2
- import type { MaybeRefOrGetter } from '@vueuse/shared'
2
+ import type { MaybeRefOrGetter } from 'vue'
3
3
  import type { FuseListItem } from '../../../types'
4
4
  import { useFuse } from '@vueuse/integrations/useFuse'
5
5
  import { useSiteConfig } from 'valaxy'
package/client/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import type { Post } from '../types'
5
5
  import './shims.d'
6
6
 
7
7
  export * from '../dist/types/index.mjs'
8
+ export * from './index'
8
9
 
9
10
  declare module '@docsearch/js' {
10
11
  function docsearch<T = any>(props: T): void
package/client/main.ts CHANGED
@@ -3,7 +3,7 @@ import { dataSymbol, initValaxyConfig, valaxyConfigSymbol } from 'valaxy'
3
3
  import { setupLayouts } from 'virtual:generated-layouts'
4
4
  import { ViteSSG } from 'vite-ssg'
5
5
 
6
- import { routes } from 'vue-router/auto-routes'
6
+ import { routes as autoRoutes } from 'vue-router/auto-routes'
7
7
  // import App from '/@valaxyjs/App.vue'
8
8
  import App from './App.vue'
9
9
 
@@ -20,13 +20,15 @@ import 'uno.css'
20
20
 
21
21
  const valaxyConfig = initValaxyConfig()
22
22
 
23
+ const routes = [...autoRoutes]
24
+
23
25
  const { redirectRoutes, useVueRouter } = valaxyConfig.value.runtimeConfig.redirects
24
26
  if (useVueRouter)
25
27
  routes.push(...redirectRoutes)
26
28
 
27
29
  // fix chinese path
28
30
  routes.forEach((i) => {
29
- i?.children?.forEach((j) => {
31
+ i?.children?.forEach((j: { path: string }) => {
30
32
  j.path = encodeURI(j.path)
31
33
  })
32
34
  })
@@ -33,9 +33,21 @@ export function formatDate(date?: string | number | Date, options: {
33
33
  * @param desc
34
34
  */
35
35
  export function sortByDate(posts: Post[], desc = true) {
36
+ return orderByMeta(posts, 'date', desc)
37
+ }
38
+
39
+ export function sortByUpdated(posts: Post[], desc = true) {
40
+ return orderByMeta(posts, 'updated', desc)
41
+ }
42
+
43
+ /**
44
+ * sort posts by date
45
+ * @param posts
46
+ */
47
+ export function orderByMeta(posts: Post[], orderBy: 'date' | 'updated' = 'date', desc = true) {
36
48
  return posts.sort((a, b) => {
37
- const aDate = +new Date(a.date || '')
38
- const bDate = +new Date(b.date || '')
49
+ const aDate = +new Date(a[orderBy] || a.date || '')
50
+ const bDate = +new Date(b[orderBy] || a.date || '')
39
51
  if (desc)
40
52
  return bDate - aDate
41
53
  else
@@ -1,7 +1,7 @@
1
1
  import 'node:process';
2
2
  import 'yargs';
3
3
  import 'yargs/helpers';
4
- export { c as cli, d as registerDevCommand, r as run, a as startValaxyDev } from '../../shared/valaxy.DjEY3xEv.mjs';
4
+ export { c as cli, d as registerDevCommand, r as run, a as startValaxyDev } from '../../shared/valaxy.DHoKJedg.mjs';
5
5
  import 'node:path';
6
6
  import 'consola';
7
7
  import 'consola/utils';
@@ -13,7 +13,7 @@ import { EditableTreeNode } from 'unplugin-vue-router';
13
13
  import Router from 'unplugin-vue-router/vite';
14
14
  import Layouts from 'vite-plugin-vue-layouts';
15
15
  import { Options as Options$1 } from 'vitepress-plugin-group-icons';
16
- import { D as DefaultTheme, R as RuntimeConfig, a as RedirectItem, V as ValaxyConfig, P as PartialDeep, b as ValaxyAddon, S as SiteConfig, U as UserSiteConfig } from '../shared/valaxy.BwiZu4ms.mjs';
16
+ import { D as DefaultTheme, R as RuntimeConfig, a as RedirectItem, V as ValaxyConfig, P as PartialDeep, b as ValaxyAddon, S as SiteConfig, U as UserSiteConfig } from '../shared/valaxy.DJquM_xq.mjs';
17
17
  import { MarkdownEnv } from 'unplugin-vue-markdown/types';
18
18
  import { KatexOptions } from 'katex';
19
19
  import MarkdownIt from 'markdown-it';
@@ -1,4 +1,4 @@
1
- export { C as ALL_ROUTE, E as EXCERPT_SEPARATOR, G as GLOBAL_STATE, P as PATHNAME_PROTOCOL_RE, V as ViteValaxyPlugins, b as build, c as cli, N as createServer, L as createValaxyPlugin, D as customElements, j as defaultSiteConfig, w as defaultValaxyConfig, F as defaultViteConfig, h as defineAddon, y as defineConfig, k as defineSiteConfig, u as defineTheme, f as defineValaxyAddon, x as defineValaxyConfig, t as defineValaxyTheme, O as encryptContent, g as generateClientRedirects, Q as getGitTimestamp, e as getIndexHtml, M as getServerInfoText, R as isExternal, U as isInstalledGlobally, S as isPath, v as loadConfigFromFile, A as mergeValaxyConfig, m as mergeViteConfigs, p as postProcessForSSG, I as processValaxyOptions, d as registerDevCommand, i as resolveAddonsConfig, Y as resolveImportPath, W as resolveImportUrl, J as resolveOptions, n as resolveSiteConfig, l as resolveSiteConfigFromRoot, o as resolveThemeConfigFromRoot, K as resolveThemeValaxyConfig, q as resolveUserThemeConfig, B as resolveValaxyConfig, z as resolveValaxyConfigFromRoot, r as run, s as ssgBuild, a as startValaxyDev, X as toAtFS, T as transformObject, H as version } from '../shared/valaxy.DjEY3xEv.mjs';
1
+ export { C as ALL_ROUTE, E as EXCERPT_SEPARATOR, G as GLOBAL_STATE, P as PATHNAME_PROTOCOL_RE, V as ViteValaxyPlugins, b as build, c as cli, N as createServer, L as createValaxyPlugin, D as customElements, j as defaultSiteConfig, w as defaultValaxyConfig, F as defaultViteConfig, h as defineAddon, y as defineConfig, k as defineSiteConfig, u as defineTheme, f as defineValaxyAddon, x as defineValaxyConfig, t as defineValaxyTheme, O as encryptContent, g as generateClientRedirects, Q as getGitTimestamp, e as getIndexHtml, M as getServerInfoText, R as isExternal, U as isInstalledGlobally, S as isPath, v as loadConfigFromFile, A as mergeValaxyConfig, m as mergeViteConfigs, p as postProcessForSSG, I as processValaxyOptions, d as registerDevCommand, i as resolveAddonsConfig, Y as resolveImportPath, W as resolveImportUrl, J as resolveOptions, n as resolveSiteConfig, l as resolveSiteConfigFromRoot, o as resolveThemeConfigFromRoot, K as resolveThemeValaxyConfig, q as resolveUserThemeConfig, B as resolveValaxyConfig, z as resolveValaxyConfigFromRoot, r as run, s as ssgBuild, a as startValaxyDev, X as toAtFS, T as transformObject, H as version } from '../shared/valaxy.DHoKJedg.mjs';
2
2
  import 'node:path';
3
3
  import 'fs-extra';
4
4
  import 'consola/utils';
@@ -471,6 +471,7 @@ function customRandom(alphabet, defaultSize, getRandom) {
471
471
  let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1;
472
472
  let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length);
473
473
  return (size = defaultSize) => {
474
+ if (!size) return ''
474
475
  let id = '';
475
476
  while (true) {
476
477
  let bytes = getRandom(step);
@@ -1567,7 +1568,7 @@ async function setupMarkdownPlugins(md, options, base = "/") {
1567
1568
  return md;
1568
1569
  }
1569
1570
 
1570
- const version = "0.26.6";
1571
+ const version = "0.26.8";
1571
1572
 
1572
1573
  const GLOBAL_STATE = {
1573
1574
  valaxyApp: void 0,
@@ -1994,7 +1995,8 @@ const defaultSiteConfig = {
1994
1995
  favicon: "/favicon.svg"
1995
1996
  },
1996
1997
  social: [],
1997
- lastUpdated: true,
1998
+ orderBy: "date",
1999
+ lastUpdated: false,
1998
2000
  license: {
1999
2001
  enabled: true,
2000
2002
  language: "",
@@ -2793,7 +2795,7 @@ function createTransformEncrypt(options) {
2793
2795
  let getValaxyDecryptTemplate = function(options2) {
2794
2796
  return [
2795
2797
  "<ClientOnly>",
2796
- `<ValaxyDecrypt :encrypted-content="${options2.encryptedContent}" hint="${options2.hint}" />`,
2798
+ `<ValaxyDecrypt :encrypted-content="${options2.encryptedContent}" hint="${options2.hint || ""}" />`,
2797
2799
  "</ClientOnly>"
2798
2800
  ].join("");
2799
2801
  };
@@ -3676,7 +3678,12 @@ function commonOptions(args) {
3676
3678
  async function generateFuseList(options) {
3677
3679
  consola.start(`Generate List for Fuse Search by (${colors.cyan("fuse.js")}) ...`);
3678
3680
  const pattern = path$1.resolve(options.userRoot, options.config.siteConfig.fuse.pattern || "pages/**/*.md");
3679
- const files = await fg(pattern);
3681
+ const files = await fg(fg.convertPathToPattern(pattern));
3682
+ if (files.length > 0) {
3683
+ consola.success(`Found ${colors.dim(files.length.toString())} markdown files for fuse search.`);
3684
+ } else {
3685
+ consola.warn(`No markdown files found for fuse search. Please check your fuse pattern: ${colors.dim(pattern)}`);
3686
+ }
3680
3687
  const posts = [];
3681
3688
  for await (const i of files) {
3682
3689
  const raw = fs.readFileSync(i, "utf-8");
@@ -528,8 +528,20 @@ interface SiteConfig {
528
528
  */
529
529
  intro?: string;
530
530
  };
531
+ /**
532
+ * order posts by 'date' or 'updated'
533
+ *
534
+ * - date: 按创建时间排序
535
+ * - updated: 按最后更新时间排序
536
+ *
537
+ * 当开启 `lastUpdated` 时,`updated` 会按照文件的更新时间自动赋值
538
+ *
539
+ * @default 'date'
540
+ */
541
+ orderBy: 'date' | 'updated';
531
542
  /**
532
543
  * show last updated time by git/mtime
544
+ * @default false
533
545
  */
534
546
  lastUpdated: boolean;
535
547
  /**
@@ -1,5 +1,5 @@
1
- import { c as PostFrontMatter, d as PageFrontMatter } from '../shared/valaxy.BwiZu4ms.mjs';
2
- export { A as Album, B as BaseFrontMatter, D as DefaultTheme, E as ExcerptType, F as FuseListItem, P as PartialDeep, i as Photo, g as Pkg, a as RedirectItem, f as RedirectRule, R as RuntimeConfig, S as SiteConfig, e as SocialLink, U as UserSiteConfig, h as UserValaxyConfig, b as ValaxyAddon, V as ValaxyConfig } from '../shared/valaxy.BwiZu4ms.mjs';
1
+ import { c as PostFrontMatter, d as PageFrontMatter } from '../shared/valaxy.DJquM_xq.mjs';
2
+ export { A as Album, B as BaseFrontMatter, D as DefaultTheme, E as ExcerptType, F as FuseListItem, P as PartialDeep, i as Photo, g as Pkg, a as RedirectItem, f as RedirectRule, R as RuntimeConfig, S as SiteConfig, e as SocialLink, U as UserSiteConfig, h as UserValaxyConfig, b as ValaxyAddon, V as ValaxyConfig } from '../shared/valaxy.DJquM_xq.mjs';
3
3
  import { Header } from '@valaxyjs/utils';
4
4
  import '@vueuse/integrations/useFuse';
5
5
  import 'medium-zoom';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "valaxy",
3
3
  "type": "module",
4
- "version": "0.26.6",
4
+ "version": "0.26.8",
5
5
  "description": "📄 Vite & Vue powered static blog generator.",
6
6
  "author": {
7
7
  "email": "me@yunyoujun.cn",
@@ -61,25 +61,25 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@antfu/install-pkg": "^1.1.0",
64
- "@antfu/utils": "^9.2.0",
64
+ "@antfu/utils": "^9.3.0",
65
65
  "@clack/prompts": "^0.11.0",
66
- "@iconify-json/ri": "^1.2.5",
67
- "@intlify/unplugin-vue-i18n": "^11.0.0",
68
- "@shikijs/transformers": "^3.12.2",
66
+ "@iconify-json/ri": "^1.2.6",
67
+ "@intlify/unplugin-vue-i18n": "^11.0.1",
68
+ "@shikijs/transformers": "^3.14.0",
69
69
  "@types/katex": "^0.16.7",
70
- "@unhead/addons": "^2.0.14",
71
- "@unhead/schema-org": "^2.0.14",
72
- "@unhead/vue": "^2.0.14",
70
+ "@unhead/addons": "^2.0.19",
71
+ "@unhead/schema-org": "^2.0.19",
72
+ "@unhead/vue": "^2.0.19",
73
73
  "@vitejs/plugin-vue": "^6.0.1",
74
74
  "@vue/devtools-api": "7.7.2",
75
- "@vueuse/core": "^13.9.0",
76
- "@vueuse/integrations": "^13.9.0",
75
+ "@vueuse/core": "^14.0.0",
76
+ "@vueuse/integrations": "^14.0.0",
77
77
  "beasties": "^0.3.5",
78
78
  "consola": "^3.4.2",
79
79
  "cross-spawn": "^7.0.6",
80
80
  "css-i18n": "^0.0.5",
81
- "dayjs": "^1.11.18",
82
- "debug": "^4.4.1",
81
+ "dayjs": "^1.11.19",
82
+ "debug": "^4.4.3",
83
83
  "define-config-ts": "^0.1.3",
84
84
  "defu": "^6.1.4",
85
85
  "ejs": "^3.1.10",
@@ -87,16 +87,16 @@
87
87
  "fast-glob": "^3.3.3",
88
88
  "feed": "^5.1.0",
89
89
  "floating-vue": "^5.2.2",
90
- "fs-extra": "^11.3.1",
90
+ "fs-extra": "^11.3.2",
91
91
  "fuse.js": "^7.1.0",
92
92
  "gray-matter": "^4.0.3",
93
93
  "hookable": "^5.5.3",
94
94
  "html-to-text": "^9.0.5",
95
- "jiti": "^2.5.1",
95
+ "jiti": "^2.6.1",
96
96
  "js-base64": "^3.7.8",
97
97
  "js-yaml": "^4.1.0",
98
- "katex": "^0.16.22",
99
- "lru-cache": "^11.2.1",
98
+ "katex": "^0.16.25",
99
+ "lru-cache": "^11.2.2",
100
100
  "markdown-it": "^14.1.0",
101
101
  "markdown-it-anchor": "^9.2.0",
102
102
  "markdown-it-async": "^2.2.0",
@@ -105,42 +105,42 @@
105
105
  "markdown-it-emoji": "^3.0.0",
106
106
  "markdown-it-footnote": "^4.0.0",
107
107
  "markdown-it-image-figures": "^2.1.1",
108
- "markdown-it-table-of-contents": "^1.0.0",
108
+ "markdown-it-table-of-contents": "^1.1.0",
109
109
  "markdown-it-task-lists": "^2.1.1",
110
110
  "medium-zoom": "^1.1.0",
111
- "mermaid": "^11.11.0",
111
+ "mermaid": "^11.12.1",
112
112
  "mlly": "^1.8.0",
113
113
  "nprogress": "^0.2.0",
114
114
  "open": "10.1.0",
115
- "ora": "^8.2.0",
115
+ "ora": "^9.0.0",
116
116
  "pascalcase": "^2.0.0",
117
117
  "pathe": "^2.0.3",
118
118
  "pinia": "^3.0.3",
119
119
  "qrcode": "^1.5.4",
120
120
  "resolve-global": "^2.0.0",
121
- "sass": "^1.92.1",
122
- "shiki": "^3.12.2",
121
+ "sass": "^1.93.3",
122
+ "shiki": "^3.14.0",
123
123
  "star-markdown-css": "^0.5.3",
124
124
  "table": "^6.9.0",
125
- "unhead": "^2.0.14",
126
- "unocss": "^66.5.0",
125
+ "unhead": "^2.0.19",
126
+ "unocss": "^66.5.4",
127
127
  "unplugin-vue-components": "28.0.0",
128
- "unplugin-vue-markdown": "^29.1.0",
129
- "unplugin-vue-router": "^0.15.0",
128
+ "unplugin-vue-markdown": "^29.2.0",
129
+ "unplugin-vue-router": "^0.16.1",
130
130
  "vanilla-lazyload": "^19.1.3",
131
- "vite": "^7.1.4",
131
+ "vite": "^7.1.12",
132
132
  "vite-dev-rpc": "^1.1.0",
133
- "vite-plugin-vue-devtools": "^8.0.1",
133
+ "vite-plugin-vue-devtools": "^8.0.3",
134
134
  "vite-plugin-vue-layouts": "^0.11.0",
135
- "vite-ssg": "^28.1.0",
135
+ "vite-ssg": "^28.2.2",
136
136
  "vite-ssg-sitemap": "^0.10.0",
137
- "vitepress-plugin-group-icons": "^1.6.3",
138
- "vue": "^3.5.21",
137
+ "vitepress-plugin-group-icons": "^1.6.5",
138
+ "vue": "^3.5.22",
139
139
  "vue-i18n": "^11.1.12",
140
- "vue-router": "^4.5.1",
140
+ "vue-router": "^4.6.3",
141
141
  "yargs": "^18.0.0",
142
- "@valaxyjs/utils": "0.26.6",
143
- "@valaxyjs/devtools": "0.26.6"
142
+ "@valaxyjs/utils": "0.26.8",
143
+ "@valaxyjs/devtools": "0.26.8"
144
144
  },
145
145
  "devDependencies": {
146
146
  "@mdit-vue/plugin-component": "^3.0.2",
@@ -159,18 +159,15 @@
159
159
  "@types/markdown-it-footnote": "^3.0.4",
160
160
  "@types/nprogress": "^0.2.3",
161
161
  "@types/pascalcase": "^1.0.3",
162
- "@types/qrcode": "^1.5.5",
163
- "@types/yargs": "^17.0.33",
162
+ "@types/qrcode": "^1.5.6",
163
+ "@types/yargs": "^17.0.34",
164
164
  "cilicili": "^0.1.1",
165
165
  "diacritics": "^1.3.0",
166
166
  "gh-pages": "^6.3.0",
167
167
  "https-localhost": "^4.7.1",
168
- "rollup-plugin-visualizer": "^6.0.3",
168
+ "rollup-plugin-visualizer": "^6.0.5",
169
169
  "unbuild": "^3.6.1"
170
170
  },
171
- "resolutions": {
172
- "vite": "catalog:build"
173
- },
174
171
  "scripts": {
175
172
  "clean": "rimraf dist",
176
173
  "build": "unbuild",
package/types/config.ts CHANGED
@@ -125,8 +125,21 @@ export interface SiteConfig {
125
125
  intro?: string
126
126
  }
127
127
 
128
+ /**
129
+ * order posts by 'date' or 'updated'
130
+ *
131
+ * - date: 按创建时间排序
132
+ * - updated: 按最后更新时间排序
133
+ *
134
+ * 当开启 `lastUpdated` 时,`updated` 会按照文件的更新时间自动赋值
135
+ *
136
+ * @default 'date'
137
+ */
138
+ orderBy: 'date' | 'updated'
139
+
128
140
  /**
129
141
  * show last updated time by git/mtime
142
+ * @default false
130
143
  */
131
144
  lastUpdated: boolean
132
145