valaxy 0.5.0 → 0.6.0

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.
Files changed (55) hide show
  1. package/README.md +0 -4
  2. package/{dist/types/index.mjs → client/app/data.ts} +0 -0
  3. package/client/components/PostCard.vue +4 -2
  4. package/client/components/ValaxyBg.vue +1 -1
  5. package/client/components/ValaxyFooter.vue +1 -1
  6. package/client/components/ValaxyToc.vue +3 -3
  7. package/client/composables/outline.ts +181 -0
  8. package/client/composables/sidebar.ts +58 -1
  9. package/client/config.ts +30 -7
  10. package/client/main.ts +4 -1
  11. package/client/modules/valaxy.ts +33 -8
  12. package/client/shims.d.ts +6 -1
  13. package/client/styles/palette.scss +6 -2
  14. package/client/utils/helper.ts +22 -0
  15. package/client/utils/sidebar.ts +26 -0
  16. package/config/index.ts +18 -0
  17. package/dist/chunk-CP3UCJ2D.js +34 -0
  18. package/dist/chunk-HCVZ2UUO.mjs +34 -0
  19. package/dist/{config-7bd43d41.d.ts → config-ad23e743.d.ts} +6 -4
  20. package/dist/index.d.ts +363 -0
  21. package/dist/index.js +1 -0
  22. package/dist/index.mjs +1 -0
  23. package/dist/node/cli.js +7 -11
  24. package/dist/node/cli.mjs +7 -11
  25. package/dist/node/index.d.ts +2 -2
  26. package/dist/node/index.js +1 -1
  27. package/dist/node/index.mjs +1 -1
  28. package/index.ts +3 -0
  29. package/node/config.ts +9 -23
  30. package/node/markdown/index.ts +21 -13
  31. package/node/markdown/markdownToVue.ts +253 -0
  32. package/node/options.ts +16 -0
  33. package/node/plugins/extendConfig.ts +4 -3
  34. package/node/plugins/index.ts +103 -6
  35. package/node/plugins/preset.ts +6 -6
  36. package/node/rss.ts +1 -1
  37. package/node/utils/getGitTimestamp.ts +13 -0
  38. package/node/utils/index.ts +11 -0
  39. package/package.json +20 -7
  40. package/shared/index.ts +1 -0
  41. package/tsup.config.ts +5 -3
  42. package/types/config.ts +7 -4
  43. package/types/data.ts +31 -0
  44. package/types/index.ts +1 -0
  45. package/types/posts.ts +1 -1
  46. package/dist/chunk-RSQONJW3.mjs +0 -86
  47. package/dist/chunk-XQIGHIAX.js +0 -86
  48. package/dist/client/index.d.ts +0 -188
  49. package/dist/client/index.js +0 -1
  50. package/dist/client/index.mjs +0 -1
  51. package/dist/posts-32f55e33.d.ts +0 -117
  52. package/dist/types/index.d.ts +0 -8
  53. package/dist/types/index.js +0 -1
  54. package/index.d.ts +0 -3
  55. package/node/plugins/markdown.ts +0 -54
package/node/rss.ts CHANGED
@@ -24,7 +24,7 @@ const markdown = MarkdownIt({
24
24
  export async function build(options: ResolvedValaxyOptions) {
25
25
  const { config } = options
26
26
 
27
- if (!config.url) {
27
+ if (!config.url || config.url === '/') {
28
28
  consola.error('You must set "config.url" to generate rss.')
29
29
  return
30
30
  }
@@ -0,0 +1,13 @@
1
+ import { spawn } from 'cross-spawn'
2
+
3
+ export function getGitTimestamp(file: string) {
4
+ return new Promise<number>((resolve, reject) => {
5
+ const child = spawn('git', ['log', '-1', '--pretty="%ci"', file])
6
+ let output = ''
7
+ child.stdout.on('data', d => (output += String(d)))
8
+ child.on('close', () => {
9
+ resolve(+new Date(output))
10
+ })
11
+ child.on('error', reject)
12
+ })
13
+ }
@@ -4,6 +4,17 @@ import globalDirs from 'global-dirs'
4
4
  import { sync as resolve } from 'resolve'
5
5
  import consola from 'consola'
6
6
 
7
+ export * from './getGitTimestamp'
8
+
9
+ /**
10
+ * transform obj for vite cde
11
+ * @param obj
12
+ * @returns
13
+ */
14
+ export const transformObject = (obj: any) => {
15
+ return `JSON.parse(${JSON.stringify(JSON.stringify(obj))})`
16
+ }
17
+
7
18
  export function slash(str: string) {
8
19
  return str.replace(/\\/g, '/')
9
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "valaxy",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "📄 Vite & Vue powered static blog generator.",
5
5
  "author": {
6
6
  "email": "me@yunyoujun.cn",
@@ -17,16 +17,22 @@
17
17
  ],
18
18
  "exports": {
19
19
  ".": {
20
- "types": "./index.d.ts",
20
+ "types": "./dist/index.d.ts",
21
21
  "require": "./dist/index.js",
22
22
  "import": "./dist/index.mjs"
23
23
  },
24
24
  "./client": "./dist/client.d.ts",
25
25
  "./client/*": "./client/*",
26
+ "./node": {
27
+ "types": "./dist/node/index.d.ts",
28
+ "require": "./dist/node/index.js",
29
+ "import": "./dist/node/index.mjs"
30
+ },
26
31
  "./*": "./*"
27
32
  },
28
33
  "main": "dist/index.js",
29
- "types": "index.d.ts",
34
+ "module": "dist/index.mjs",
35
+ "types": "dist/index.d.ts",
30
36
  "bin": {
31
37
  "vala": "./bin/valaxy.js",
32
38
  "valaxy": "./bin/valaxy.js"
@@ -35,6 +41,7 @@
35
41
  "node": ">=14.0.0"
36
42
  },
37
43
  "dependencies": {
44
+ "@antfu/utils": "^0.5.2",
38
45
  "@ctrl/tinycolor": "^3.4.1",
39
46
  "@docsearch/css": "^3.1.0",
40
47
  "@docsearch/js": "^3.1.0",
@@ -42,15 +49,19 @@
42
49
  "@iconify-json/ri": "^1.1.2",
43
50
  "@intlify/vite-plugin-vue-i18n": "^3.4.0",
44
51
  "@vitejs/plugin-vue": "^2.3.3",
45
- "@vueuse/core": "^8.7.3",
52
+ "@vueuse/core": "^8.7.4",
46
53
  "@vueuse/head": "^0.7.6",
47
54
  "consola": "^2.15.3",
48
55
  "critters": "^0.0.16",
56
+ "cross-spawn": "^7.0.3",
49
57
  "dayjs": "^1.11.3",
50
58
  "escape-html": "^1.0.3",
51
59
  "feed": "^4.2.2",
60
+ "gray-matter": "^4.0.3",
52
61
  "katex": "^0.16.0",
53
62
  "kolorist": "^1.5.1",
63
+ "lru-cache": "^7.10.1",
64
+ "markdown-it": "^13.0.1",
54
65
  "markdown-it-anchor": "^8.6.4",
55
66
  "markdown-it-attrs": "^4.1.4",
56
67
  "markdown-it-container": "^3.0.0",
@@ -64,13 +75,13 @@
64
75
  "prism-theme-vars": "^0.2.3",
65
76
  "prismjs": "^1.28.0",
66
77
  "sass": "^1.52.3",
78
+ "shiki": "^0.10.1",
67
79
  "star-markdown-css": "^0.3.3",
68
80
  "unconfig": "^0.3.4",
69
- "unocss": "^0.39.0",
81
+ "unocss": "^0.39.3",
70
82
  "unplugin-vue-components": "^0.19.6",
71
83
  "vite": "^2.9.12",
72
84
  "vite-plugin-inspect": "^0.5.0",
73
- "vite-plugin-md": "^0.13.1",
74
85
  "vite-plugin-pages": "^0.24.2",
75
86
  "vite-plugin-vue-layouts": "^0.6.0",
76
87
  "vite-ssg": "0.19.2",
@@ -81,7 +92,9 @@
81
92
  "yargs": "^17.5.1"
82
93
  },
83
94
  "devDependencies": {
95
+ "@types/cross-spawn": "^6.0.2",
84
96
  "@types/katex": "^0.14.0",
97
+ "@types/lru-cache": "^7.10.10",
85
98
  "@types/markdown-it-link-attributes": "^3.0.1",
86
99
  "@types/nprogress": "^0.2.0",
87
100
  "@types/yargs": "^17.0.10",
@@ -92,7 +105,7 @@
92
105
  },
93
106
  "scripts": {
94
107
  "build": "rimraf dist && tsup --splitting",
95
- "dev": "tsup --watch --splitting",
108
+ "dev": "tsup --splitting --watch",
96
109
  "lint": "eslint \"**/*.{vue,ts,js}\"",
97
110
  "preview": "vite preview",
98
111
  "preview-https": "serve dist"
@@ -0,0 +1 @@
1
+ export const EXTERNAL_URL_RE = /^https?:/i
package/tsup.config.ts CHANGED
@@ -3,20 +3,22 @@ import { defineConfig } from 'tsup'
3
3
  export default defineConfig((options) => {
4
4
  return {
5
5
  entry: [
6
- 'client/index.ts',
6
+ 'index.ts',
7
+ // 'client/index.ts',
7
8
  'node/index.ts',
8
9
  'node/cli.ts',
9
- 'types/index.ts',
10
+ // 'types/index.ts',
10
11
  ],
11
12
  // https://tsup.egoist.sh/#code-splitting
12
13
  // Code splitting currently only works with the esm output format, and it's enabled by default. If you want code splitting for cjs output format as well, try using --splitting flag which is an experimental feature to get rid of the limitation in esbuild.
13
- splitting: true,
14
+ // splitting: true,
14
15
  clean: true,
15
16
  dts: true,
16
17
  format: ['cjs', 'esm'],
17
18
  minify: !options.watch,
18
19
  external: [
19
20
  '@valaxyjs/config',
21
+ '@valaxyjs/context',
20
22
  'valaxy-theme-yun',
21
23
  ],
22
24
  }
package/types/config.ts CHANGED
@@ -1,10 +1,7 @@
1
1
  import type { PartialDeep } from 'type-fest'
2
2
  import type { VitePluginConfig } from 'unocss/vite'
3
- import type Markdown from 'vite-plugin-md'
4
3
  import type { MarkdownOptions } from '../node/markdown'
5
4
 
6
- export type ViteMdOptions = Parameters<typeof Markdown>[0]
7
-
8
5
  export type ValaxyThemeConfig = Record<string, any>
9
6
 
10
7
  export interface SocialLink {
@@ -32,6 +29,7 @@ export interface AlgoliaSearchOptions {
32
29
  initialQuery?: string
33
30
  }
34
31
 
32
+ // packages/valaxy/node/config.ts
35
33
  export interface ValaxyConfig<T = ValaxyThemeConfig> {
36
34
  /**
37
35
  * Default language
@@ -42,6 +40,7 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
42
40
  /**
43
41
  * You site url in web, required for ssg & rss
44
42
  * @description 站点的 URL,SSG & RSS 需要(譬如生成版权处文章永久链接)
43
+ * @default '/'
45
44
  */
46
45
  url: string
47
46
  /**
@@ -84,6 +83,11 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
84
83
  }
85
84
  }
86
85
 
86
+ /**
87
+ * show last updated time by git
88
+ */
89
+ lastUpdated: boolean
90
+
87
91
  /**
88
92
  * icon for your website
89
93
  */
@@ -203,7 +207,6 @@ export interface ValaxyConfig<T = ValaxyThemeConfig> {
203
207
  /**
204
208
  * for markdown
205
209
  */
206
- markdown: ViteMdOptions
207
210
  markdownIt: MarkdownOptions
208
211
  }
209
212
 
package/types/data.ts ADDED
@@ -0,0 +1,31 @@
1
+ import type { Post } from './posts'
2
+
3
+ export interface Header {
4
+ level: number
5
+ title: string
6
+ slug: string
7
+ /**
8
+ * i18n
9
+ */
10
+ lang?: string
11
+ }
12
+
13
+ export interface PageData {
14
+ path: string
15
+ relativePath: string
16
+ title: string
17
+ titleTemplate?: string
18
+ description: string
19
+ headers: Header[]
20
+ frontmatter: Post
21
+ lastUpdated?: number
22
+ }
23
+
24
+ export interface PageDataPayload {
25
+ path: string
26
+ pageData: PageData
27
+ }
28
+
29
+ export type HeadConfig =
30
+ | [string, Record<string, string>]
31
+ | [string, Record<string, string>, string]
package/types/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './config'
2
2
  export * from './posts'
3
+ export * from './data'
package/types/posts.ts CHANGED
@@ -118,5 +118,5 @@ export interface Post extends Record<string, any> {
118
118
  * enable markdown-body class
119
119
  * @description 是否启用默认的 markdown 样式
120
120
  */
121
- markdown: boolean
121
+ markdown?: boolean
122
122
  }