valaxy 0.1.1 → 0.2.1

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 (96) hide show
  1. package/bin/valaxy.js +1 -1
  2. package/dist/chunk-B2JVVNA4.js +88 -0
  3. package/dist/chunk-FH6NMGNX.mjs +88 -0
  4. package/dist/chunk-TSLYS2VY.js +1 -0
  5. package/dist/chunk-U4ZDCBEC.mjs +1 -0
  6. package/dist/config-24b4f209.d.ts +188 -0
  7. package/dist/index.d.ts +337 -150
  8. package/dist/index.js +1 -1
  9. package/dist/index.mjs +1 -1
  10. package/dist/{cli.d.ts → node/cli.d.ts} +0 -0
  11. package/dist/node/cli.js +45 -0
  12. package/dist/node/cli.mjs +45 -0
  13. package/dist/node/index.d.ts +46 -0
  14. package/dist/node/index.js +1 -0
  15. package/dist/node/index.mjs +1 -0
  16. package/package.json +23 -20
  17. package/src/client/components/PostCard.vue +16 -17
  18. package/src/client/components/PostList.vue +3 -3
  19. package/src/client/components/ValaxyCopyright.vue +1 -1
  20. package/src/client/components/ValaxyFooter.vue +1 -1
  21. package/src/client/components/ValaxyMd.vue +1 -1
  22. package/src/client/components/ValaxyOverlay.vue +4 -4
  23. package/src/client/components/ValaxyPagination.vue +14 -11
  24. package/src/client/components/ValaxyRightSidebar.vue +2 -2
  25. package/src/client/components/ValaxySidebar.vue +4 -10
  26. package/src/client/components/ValaxyToc.vue +12 -10
  27. package/src/client/composables/category.ts +24 -5
  28. package/src/client/composables/comments/index.ts +1 -0
  29. package/src/client/composables/comments/twikoo.ts +37 -0
  30. package/src/client/composables/comments/waline.ts +8 -5
  31. package/src/client/composables/common.ts +3 -4
  32. package/src/client/composables/post.ts +26 -1
  33. package/src/client/composables/search/algolia.ts +2 -1
  34. package/src/client/composables/sidebar.ts +2 -2
  35. package/src/client/composables/tag.ts +9 -2
  36. package/src/client/composables/widgets/backToTop.ts +10 -4
  37. package/src/client/index.html +5 -0
  38. package/src/client/layouts/404.vue +5 -1
  39. package/src/client/main.ts +2 -9
  40. package/src/client/modules/valaxy.ts +31 -13
  41. package/src/client/shims.d.ts +5 -5
  42. package/src/client/styles/common/button.scss +3 -5
  43. package/src/client/styles/common/code.scss +181 -9
  44. package/src/client/styles/common/custom-blocks.scss +84 -0
  45. package/src/client/styles/common/hamburger.scss +2 -2
  46. package/src/client/styles/common/markdown.scss +4 -6
  47. package/src/client/styles/common/sidebar.scss +3 -3
  48. package/src/client/styles/common/transition.scss +2 -2
  49. package/src/client/styles/css-vars.scss +39 -0
  50. package/src/client/styles/global/helper.scss +2 -2
  51. package/src/client/styles/global/i18n.scss +20 -0
  52. package/src/client/styles/global/index.scss +1 -1
  53. package/src/client/styles/global/nprogress.scss +1 -1
  54. package/src/client/styles/global/reset.scss +1 -1
  55. package/src/client/styles/index.scss +21 -8
  56. package/src/client/styles/mixins/config.scss +1 -1
  57. package/src/client/styles/mixins/index.scss +1 -0
  58. package/src/client/styles/palette.scss +58 -44
  59. package/src/client/styles/vars.scss +1 -13
  60. package/src/client/styles/widgets/banner.scss +2 -2
  61. package/src/client/utils/index.ts +0 -2
  62. package/src/node/build.ts +20 -1
  63. package/src/node/cli.ts +32 -19
  64. package/src/node/markdown/headings.ts +3 -2
  65. package/src/node/markdown/highlight.ts +50 -0
  66. package/src/node/markdown/highlightLines.ts +96 -0
  67. package/src/node/markdown/index.ts +23 -12
  68. package/src/node/markdown/markdown-it-container.ts +9 -1
  69. package/src/node/markdown/markdown-it-katex.ts +20 -10
  70. package/src/node/markdown/parseHeader.ts +4 -2
  71. package/src/node/options.ts +3 -1
  72. package/src/node/plugins/index.ts +53 -24
  73. package/src/node/plugins/markdown.ts +1 -1
  74. package/src/node/plugins/preset.ts +46 -10
  75. package/src/node/plugins/unocss.ts +21 -19
  76. package/src/node/rss.ts +127 -0
  77. package/src/node/server.ts +1 -1
  78. package/src/node/shims.d.ts +15 -0
  79. package/src/node/utils/cli.ts +0 -1
  80. package/src/node/vite.ts +7 -15
  81. package/src/types/config.ts +28 -2
  82. package/src/types/posts.ts +6 -1
  83. package/tsup.config.ts +1 -0
  84. package/dist/build-VGAF4K5S.js +0 -1
  85. package/dist/build-Y5F7AZ2V.mjs +0 -1
  86. package/dist/chunk-5KQ3UFYI.js +0 -1
  87. package/dist/chunk-ESCOXVP6.mjs +0 -83
  88. package/dist/chunk-JWA76JND.mjs +0 -1
  89. package/dist/chunk-WYCH73X6.js +0 -83
  90. package/dist/cli.js +0 -6
  91. package/dist/cli.mjs +0 -6
  92. package/src/client/pages/about/index.md +0 -5
  93. package/src/client/pages/posts/index.md +0 -5
  94. package/src/client/styles/css-vars/dark.scss +0 -17
  95. package/src/client/styles/css-vars/index.scss +0 -18
  96. package/src/client/styles/css-vars/light.scss +0 -9
@@ -53,7 +53,7 @@ if (props.frontmatter.codepen)
53
53
  <slot v-if="typeof frontmatter.end !== 'undefined'" name="end">
54
54
  <div m="y-4" class="end flex justify-center items-center">
55
55
  <hr class="line inline-flex" w="full" m="!y-2">
56
- <span p="x-4" font="serif" class="whitespace-nowrap">
56
+ <span p="x-4" font="serif bold" class="whitespace-nowrap">
57
57
  {{ frontmatter.end ? 'Q.E.D.' : 'To Be Continued.' }}
58
58
  </span>
59
59
  <hr class="line inline-flex" w="full" m="!y-2">
@@ -8,7 +8,7 @@ withDefaults(defineProps<{
8
8
 
9
9
  <template>
10
10
  <transition name="fade">
11
- <div v-if="show" class="val-overlay backdrop-filter backdrop-blur" />
11
+ <div v-if="show" class="va-overlay backdrop-filter backdrop-blur" />
12
12
  </transition>
13
13
  </template>
14
14
 
@@ -18,14 +18,14 @@ withDefaults(defineProps<{
18
18
  @use "~/styles/vars" as *;
19
19
  @use "~/styles/mixins" as *;
20
20
 
21
- .val-overlay {
21
+ .va-overlay {
22
22
  background-color: rgba(0, 0, 0, 0.3);
23
23
  position: fixed;
24
24
  top: 0;
25
25
  right: 0;
26
26
  bottom: 0;
27
27
  left: 0;
28
- z-index: map.get($z-index, 'sidebar') - 1;
28
+ z-index: calc(var(--yun-z-sidebar) - 1);
29
29
  transition: opacity 0.4s;
30
30
 
31
31
  display: none;
@@ -37,7 +37,7 @@ withDefaults(defineProps<{
37
37
  }
38
38
 
39
39
  @include mobile {
40
- .val-overlay {
40
+ .va-overlay {
41
41
  display: block;
42
42
  }
43
43
  }
@@ -30,14 +30,17 @@ const surLen = computed(() => {
30
30
  })
31
31
 
32
32
  const showPage = (i: number) => {
33
- if (i === 1) return true
34
- else if (i === totalPages.value) return true
33
+ if (i === 1)
34
+ return true
35
+ else if (i === totalPages.value)
36
+ return true
35
37
  return i > props.curPage - surLen.value && i < props.curPage + surLen.value
36
38
  }
37
39
 
38
40
  const jumpTo = (page: number) => {
39
41
  emit('page-change', page)
40
- if (page === 1) return '/'
42
+ if (page === 1)
43
+ return '/'
41
44
  else return `/page/${page}`
42
45
  }
43
46
  </script>
@@ -69,12 +72,12 @@ const jumpTo = (page: number) => {
69
72
  <style lang="scss">
70
73
  :root {
71
74
  --page-btn-bg-color: rgba(255, 255, 255, 0.5);
72
- --page-btn-hover-bg-color: var(--yun-c-primary-lighter);
73
- --page-btn-active-bg-color: var(--yun-c-primary-light);
75
+ --page-btn-hover-bg-color: var(--va-c-primary-lighter);
76
+ --page-btn-active-bg-color: var(--va-c-primary-light);
74
77
  }
75
78
 
76
79
  .dark {
77
- --page-btn-bg-color: var(--yun-c-bg-light);
80
+ --page-btn-bg-color: var(--va-c-bg-light);
78
81
  }
79
82
 
80
83
  .pagination {
@@ -90,30 +93,30 @@ const jumpTo = (page: number) => {
90
93
  width: 2rem;
91
94
  height: 2rem;
92
95
  margin: 0;
93
- transition: background-color var(--yun-transition-duration) ease;
96
+ transition: background-color var(--va-transition-duration) ease;
94
97
  }
95
98
 
96
99
  .prev, .next, .page-number {
97
100
  cursor: pointer;
98
101
 
99
- color: var(--yun-c-text);
102
+ color: var(--va-c-text);
100
103
  text-decoration: none;
101
104
  background-color: var(--page-btn-bg-color);
102
105
 
103
106
  &:hover {
104
- color: var(--yun-c-bg);
107
+ color: var(--va-c-bg);
105
108
  background: var(--page-btn-hover-bg-color);
106
109
  }
107
110
 
108
111
  &:active {
109
- color: var(--yun-c-bg);
112
+ color: var(--va-c-bg);
110
113
  background: var(--page-btn-active-bg-color);
111
114
  }
112
115
 
113
116
  &.active {
114
117
  font-weight: normal;
115
118
  background: var(--page-btn-active-bg-color);
116
- color: var(--yun-c-bg);
119
+ color: var(--va-c-bg);
117
120
  cursor: default;
118
121
  }
119
122
  }
@@ -7,7 +7,7 @@ defineProps<{ frontmatter: Post }>()
7
7
  </script>
8
8
 
9
9
  <template>
10
- <aside class="right-sidebar val-card relative" m="l-4" text="center">
10
+ <aside class="right-sidebar va-card relative" m="l-4" text="center">
11
11
  <h2 v-if="frontmatter.toc !== false" m="t-6 b-2" font="serif black">
12
12
  {{ t('sidebar.toc') }}
13
13
  </h2>
@@ -24,7 +24,7 @@ defineProps<{ frontmatter: Post }>()
24
24
 
25
25
  <style lang="scss">
26
26
  .right-sidebar {
27
- width: var(--yun-sidebar-width-mobile);
27
+ width: var(--va-sidebar-width-mobile);
28
28
  }
29
29
  .right-sidebar-container {
30
30
  top: 1rem;
@@ -11,25 +11,19 @@ const isHome = useLayout('home')
11
11
 
12
12
  <ValaxyHamburger :active="app.isSidebarOpen" class="menu-btn sidebar-toggle yun-icon-btn" :class="isHome ? '' : 'md:hidden'" @click="app.toggleSidebar()" />
13
13
 
14
- <aside class="val-card" :class="['sidebar', app.isSidebarOpen && 'open', !isHome && 'md:translate-x-0']">
15
- <YunSidebar />
16
-
17
- <YunConfig />
14
+ <aside class="va-card" :class="['sidebar', app.isSidebarOpen && 'open', !isHome && 'md:translate-x-0']">
15
+ <slot />
18
16
  </aside>
19
17
  </template>
20
18
 
21
- <style lang="scss">
22
- @use "sass:map";
23
-
24
- @use "~/styles/vars" as *;
25
-
19
+ <style>
26
20
  .menu-btn {
27
21
  display: inline-flex;
28
22
  position: fixed;
29
23
  left: 0.8rem;
30
24
  top: 0.6rem;
31
25
  line-height: 1;
32
- z-index: map.get($z-index, 'menu-btn');
26
+ z-index: var(--yun-z-menu-btn);
33
27
  cursor: pointer;
34
28
  }
35
29
  </style>
@@ -20,22 +20,22 @@ function getStylesByLevel(level: number) {
20
20
  </script>
21
21
 
22
22
  <template>
23
- <ul class="val-toc" p="l-4">
24
- <li v-for="header, i in headers" :key="i" :style="getStylesByLevel(header.level)">
23
+ <ul class="va-toc" p="l-4">
24
+ <li v-for="header, i in headers" :key="i" class="va-toc-item" :style="getStylesByLevel(header.level)">
25
25
  <a class="toc-link-item" :href="`#${header.slug}`">{{ header.title }}</a>
26
26
  </li>
27
27
  </ul>
28
28
  </template>
29
29
 
30
30
  <style lang="scss">
31
- .val-toc {
31
+ .va-toc {
32
32
  top: 10px;
33
33
  width: var(--yun-sidebar-width-mobile);
34
34
 
35
- background-color: var(--yun-c-bg-light);
35
+ background-color: var(--va-c-bg-light);
36
36
 
37
37
  font-size: 1rem;
38
- font-family: var(--yun-font-serif);
38
+ font-family: var(--va-font-serif);
39
39
  font-weight: 900;
40
40
  line-height: 1.6;
41
41
 
@@ -44,26 +44,28 @@ function getStylesByLevel(level: number) {
44
44
  a {
45
45
  display: block;
46
46
  color: var(--c-toc-link);
47
- transition: color var(--yun-transition-duration);
47
+ transition: color var(--va-transition-duration);
48
48
 
49
49
  overflow: hidden;
50
50
  white-space: nowrap;
51
51
  text-overflow: ellipsis;
52
52
 
53
+ font-weight: 900;
54
+
53
55
  &:hover {
54
- color: var(--yun-c-text);
56
+ color: var(--va-c-text);
55
57
  }
56
58
  }
57
59
 
58
60
  .toc-link-item {
59
- color: var(--yun-c-text-light);
61
+ color: var(--va-c-text-light);
60
62
 
61
63
  &:hover {
62
- color: var(--yun-c-text);
64
+ color: var(--va-c-text);
63
65
  }
64
66
 
65
67
  &.active {
66
- color: var(--yun-c-primary);
68
+ color: var(--va-c-primary);
67
69
  }
68
70
  }
69
71
  }
@@ -1,3 +1,4 @@
1
+ import { unref } from 'vue'
1
2
  import type { Post } from '../../types'
2
3
  import { usePostList } from './post'
3
4
 
@@ -20,11 +21,12 @@ export type Categories = Map<string, Category>
20
21
  * get categories from posts
21
22
  * @returns
22
23
  */
23
- export function useCategory() {
24
- const posts = usePostList()
24
+ export function useCategory(category?: string, posts: Post[] = []): ParentCategory {
25
+ if (!posts.length)
26
+ posts = unref(usePostList())
25
27
 
26
28
  const categoryMap: Category = {
27
- total: posts.value.length,
29
+ total: posts.length,
28
30
  children: new Map([
29
31
  ['Uncategorized', { total: 0, posts: [] }],
30
32
  ]),
@@ -32,7 +34,7 @@ export function useCategory() {
32
34
 
33
35
  const uncategorized = categoryMap.children.get('Uncategorized') as PostCategory
34
36
 
35
- posts.value.forEach((post: Post) => {
37
+ posts.forEach((post: Post) => {
36
38
  if (post.categories) {
37
39
  if (Array.isArray(post.categories)) {
38
40
  const len = post.categories.length
@@ -97,5 +99,22 @@ export function useCategory() {
97
99
  if (uncategorized!.total === 0)
98
100
  categoryMap.children?.delete('Uncategorized')
99
101
 
100
- return categoryMap
102
+ if (!category) {
103
+ return categoryMap
104
+ }
105
+ else {
106
+ const categoryItem = categoryMap.children.get(category)
107
+ if (categoryItem) {
108
+ return {
109
+ total: categoryItem?.total,
110
+ children: new Map([
111
+ [category, categoryItem],
112
+ ]),
113
+ }
114
+ }
115
+ else {
116
+ console.warn(`Do not have category: ${category}`)
117
+ return categoryMap
118
+ }
119
+ }
101
120
  }
@@ -1 +1,2 @@
1
+ export * from './twikoo'
1
2
  export * from './waline'
@@ -0,0 +1,37 @@
1
+ import { isClient, useScriptTag } from '@vueuse/core'
2
+ import { useI18n } from 'vue-i18n'
3
+ import { useRoute } from 'vue-router'
4
+
5
+ export function useTwikoo(options: {} = {}) {
6
+ const route = useRoute()
7
+
8
+ const { locale } = useI18n()
9
+
10
+ let twikoo: any
11
+
12
+ /**
13
+ * init waline
14
+ * @param options waline options
15
+ * @returns
16
+ */
17
+ function initTwikoo(options: {} = {}) {
18
+ if (!isClient)
19
+ return
20
+
21
+ const defaultOptions = {
22
+ el: '.comment #tcomment',
23
+ lang: locale.value,
24
+ path: route.path,
25
+ }
26
+ const twikooOptions = Object.assign(defaultOptions, options)
27
+ return window.twikoo.init(twikooOptions)
28
+ }
29
+
30
+ // 直接使用 CDN
31
+ useScriptTag('//cdn.jsdelivr.net/npm/twikoo@1.5.1/dist/twikoo.all.min.js', () => {
32
+ twikoo = initTwikoo(options)
33
+ })
34
+
35
+ // eslint-disable-next-line no-console
36
+ console.log(twikoo)
37
+ }
@@ -16,7 +16,8 @@ export function useWaline(options: {} = {}) {
16
16
  * @returns
17
17
  */
18
18
  function initWaline(options: {} = {}) {
19
- if (!isClient) return
19
+ if (!isClient)
20
+ return
20
21
 
21
22
  const defaultOptions = {
22
23
  el: '.comment #waline',
@@ -30,7 +31,6 @@ export function useWaline(options: {} = {}) {
30
31
  path: route.path,
31
32
  }
32
33
  const walineOptions = Object.assign(defaultOptions, options)
33
- // @ts-expect-error waline type
34
34
  return window.Waline(walineOptions)
35
35
  }
36
36
 
@@ -40,21 +40,24 @@ export function useWaline(options: {} = {}) {
40
40
  })
41
41
 
42
42
  watch(() => route.path, (path) => {
43
- if (!waline) return
43
+ if (!waline)
44
+ return
44
45
  waline.update({
45
46
  path,
46
47
  })
47
48
  })
48
49
 
49
50
  watch(locale, (lang) => {
50
- if (!waline) return
51
+ if (!waline)
52
+ return
51
53
  waline.update({
52
54
  lang,
53
55
  })
54
56
  })
55
57
 
56
58
  onUnmounted(() => {
57
- if (!waline) return
59
+ if (!waline)
60
+ return
58
61
  waline.destroy()
59
62
  })
60
63
  }
@@ -1,7 +1,7 @@
1
1
  import { useRoute } from 'vue-router'
2
2
  import { computed } from 'vue'
3
+ import { isClient } from '@vueuse/core'
3
4
 
4
- import { isDev } from '../..'
5
5
  import type { Post } from '../../types'
6
6
  import { useConfig } from '../config'
7
7
 
@@ -9,8 +9,6 @@ export function useFrontmatter() {
9
9
  const route = useRoute()
10
10
  const frontmatter = computed<Post>(() => route.meta.frontmatter)
11
11
 
12
- // eslint-disable-next-line no-console
13
- if (isDev) console.log(frontmatter.value)
14
12
  return frontmatter
15
13
  }
16
14
 
@@ -21,7 +19,8 @@ export function useFullUrl() {
21
19
  const config = useConfig()
22
20
  const route = useRoute()
23
21
  const url = computed(() => {
24
- const origin = config.value.url || window?.location.origin
22
+ const siteUrl = config.value.url.endsWith('/') ? config.value.url.slice(0, -1) : config.value.url
23
+ const origin = siteUrl || (isClient && window.location.origin)
25
24
  return origin + route.path
26
25
  })
27
26
  return url
@@ -1,8 +1,18 @@
1
- import type { StyleValue } from 'vue'
1
+ import type { Ref, StyleValue } from 'vue'
2
2
  import { computed } from 'vue'
3
3
  import { useRoute, useRouter } from 'vue-router'
4
+ import { useI18n } from 'vue-i18n'
4
5
  import { useThemeConfig } from '../config'
5
6
  import { sortByDate } from '../utils'
7
+ import type { Post } from '../../types'
8
+
9
+ export const usePostTitle = (post: Ref<Post>) => {
10
+ const { locale } = useI18n()
11
+ return computed(() => {
12
+ const lang = locale.value === 'zh-CN' ? 'zh' : locale.value
13
+ return post.value[`title_${lang}`] || post.value.title
14
+ })
15
+ }
6
16
 
7
17
  /**
8
18
  * get post list
@@ -33,6 +43,21 @@ export function usePostList(params: {
33
43
  })
34
44
  }
35
45
 
46
+ /**
47
+ * get all page
48
+ * @returns
49
+ */
50
+ export function usePageList() {
51
+ const router = useRouter()
52
+ return computed(() => {
53
+ const routes = router.getRoutes()
54
+ .map((i) => {
55
+ return Object.assign({ path: i.path, excerpt: i.meta.excerpt }, i.meta.frontmatter)
56
+ })
57
+ return routes
58
+ })
59
+ }
60
+
36
61
  /**
37
62
  * get prev and next post
38
63
  * @param path
@@ -13,7 +13,8 @@ export function useAlgoliaSearch(config: {
13
13
  per_page: number
14
14
  }
15
15
  }) {
16
- if (!isClient) return
16
+ if (!isClient)
17
+ return
17
18
 
18
19
  const route = useRoute()
19
20
  const { t } = useI18n()
@@ -30,7 +30,7 @@ export function useActiveSidebarLinks() {
30
30
  deactiveLink(activeLink)
31
31
  deactiveLink(rootActiveLink)
32
32
 
33
- activeLink = document.querySelector(`.val-toc a[href="${hash}"]`)
33
+ activeLink = document.querySelector(`.va-toc a[href="${hash}"]`)
34
34
 
35
35
  if (!activeLink)
36
36
  return
@@ -70,7 +70,7 @@ export function useActiveSidebarLinks() {
70
70
 
71
71
  function getSidebarLinks(): HTMLAnchorElement[] {
72
72
  return [].slice.call(
73
- document.querySelectorAll('.val-toc a.toc-link-item'),
73
+ document.querySelectorAll('.va-toc a.toc-link-item'),
74
74
  )
75
75
  }
76
76
 
@@ -9,11 +9,18 @@ export type Tags = Map<string, {
9
9
  /**
10
10
  * get utils about tags
11
11
  */
12
- export function useTags() {
12
+ export function useTags(options: {
13
+ /**
14
+ * Primary Color
15
+ */
16
+ primary: string
17
+ } = {
18
+ primary: '#0078E7',
19
+ }) {
13
20
  const tags = useTag()
14
21
 
15
22
  const gray = new TinyColor('#999999')
16
- const primaryColor = new TinyColor(getComputedStyle(document.documentElement).getPropertyValue('--yun-c-primary'))
23
+ const primaryColor = new TinyColor(options.primary)
17
24
 
18
25
  const getTagStyle = (count: number) => {
19
26
  const counts = Array.from(tags).map(([_, value]) => value.count)
@@ -1,5 +1,5 @@
1
- import { useWindowScroll } from '@vueuse/core'
2
- import { computed } from 'vue'
1
+ import { isClient, useWindowScroll } from '@vueuse/core'
2
+ import { computed, ref } from 'vue'
3
3
 
4
4
  /**
5
5
  * You can use href="#" to back to top
@@ -13,10 +13,16 @@ export function useBackToTop(options: {
13
13
  } = {
14
14
  offset: 100,
15
15
  }) {
16
- const { y } = useWindowScroll()
16
+ if (!isClient) {
17
+ return {
18
+ percentage: ref(0),
19
+ show: ref(false),
20
+ }
21
+ }
17
22
 
23
+ const { y } = useWindowScroll()
18
24
  const percentage = computed(() => {
19
- return y.value / document.body.clientHeight
25
+ return y.value / (document.body.scrollHeight - window.innerHeight)
20
26
  })
21
27
 
22
28
  const show = computed(() => y.value > options.offset)
@@ -1,5 +1,6 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
+
3
4
  <head>
4
5
  <meta charset="UTF-8">
5
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -14,11 +15,15 @@
14
15
  const setting = localStorage.getItem('vueuse-color-scheme') || 'auto'
15
16
  if (setting === 'dark' || (prefersDark && setting !== 'light'))
16
17
  document.documentElement.classList.toggle('dark', true)
18
+ const locale = localStorage.getItem('valaxy-locale') || 'en'
19
+ document.documentElement.setAttribute('lang', locale)
17
20
  })()
18
21
  </script>
19
22
  </head>
23
+
20
24
  <body class="font-sans">
21
25
  <div id="app"></div>
22
26
  <script type="module" src="/main.ts"></script>
23
27
  </body>
28
+
24
29
  </html>
@@ -7,7 +7,11 @@ const { t } = useI18n()
7
7
  </script>
8
8
 
9
9
  <template>
10
- <ValaxySidebar />
10
+ <ValaxySidebar>
11
+ <slot name="sidebar">
12
+ <YunSidebar />
13
+ </slot>
14
+ </ValaxySidebar>
11
15
 
12
16
  <main class="yun-main" text="center">
13
17
  <YunCard m="4" p="10" text="yellow-600">
@@ -5,19 +5,12 @@ import App from './App.vue'
5
5
 
6
6
  import '@unocss/reset/tailwind.css'
7
7
 
8
- // markdown css
9
- import 'star-markdown-css/src/scss/theme/yun.scss'
10
-
11
- import './styles/css-vars/index.scss'
12
- import './styles/css-vars/light.scss'
13
- import './styles/css-vars/dark.scss'
14
- import './styles/index.scss'
15
-
8
+ // generate user styles
16
9
  import '/@valaxyjs/styles'
17
10
 
18
11
  import 'uno.css'
19
12
 
20
- const routes = setupLayouts(generatedRoutes)
13
+ const routes = setupLayouts(__DEV__ ? generatedRoutes : generatedRoutes.filter(i => !i.meta?.frontmatter.draft))
21
14
 
22
15
  // https://github.com/antfu/vite-ssg
23
16
  export const createApp = ViteSSG(
@@ -1,20 +1,36 @@
1
1
  import { createI18n } from 'vue-i18n'
2
+
3
+ /*
4
+ * All i18n resources specified in the plugin `include` option can be loaded
5
+ * at once using the import syntax
6
+ *
7
+ * Not support ssr https://github.com/intlify/bundle-tools/issues/78
8
+ */
9
+ // import messages from '@intlify/vite-plugin-vue-i18n/messages'
10
+
11
+ import { useStorage } from '@vueuse/core'
2
12
  import { initConfig, valaxyConfigSymbol } from '../config'
3
- import { isDev } from '..'
13
+
4
14
  import type { UserModule } from '~/types'
5
15
 
16
+ // @ts-expect-error virtual
17
+ import messages from '/@valaxyjs/locales'
18
+
6
19
  // Import i18n resources
7
20
  // https://vitejs.dev/guide/features.html#glob-import
8
21
  //
9
22
  // Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
10
- const messages = Object.fromEntries(
11
- Object.entries(
12
- import.meta.globEager('../locales/*.y(a)?ml'))
13
- .map(([key, value]) => {
14
- const yaml = key.endsWith('.yaml')
15
- return [key.slice(11, yaml ? -5 : -4), value.default]
16
- }),
17
- )
23
+ // const messages = Object.fromEntries(
24
+ // Object.entries(
25
+ // import.meta.globEager('../locales/*.y(a)?ml'))
26
+ // .map(([key, value]) => {
27
+ // const yaml = key.endsWith('.yaml')
28
+ // return [key.slice(11, yaml ? -5 : -4), value.default]
29
+ // }),
30
+ // )
31
+
32
+ // import zh from '../../../../../demo/yun/locales/zh-CN.yml'
33
+ // import en from '../../../../../demo/yun/locales/en.yml'
18
34
 
19
35
  function shouldHotReload(payload: any): boolean {
20
36
  const payloadPath = payload.path.replace(/(\bindex)?\.md$/, '')
@@ -25,19 +41,21 @@ function shouldHotReload(payload: any): boolean {
25
41
  // https://github.com/antfu/vite-plugin-pwa#automatic-reload-when-new-content-available
26
42
  export const install: UserModule = ({ app, router }) => {
27
43
  // inject valaxy config before modules
28
- const valaxyConfigRef = initConfig()
29
- app.provide(valaxyConfigSymbol, valaxyConfigRef)
44
+ const config = initConfig()
45
+ app.provide(valaxyConfigSymbol, config)
46
+
47
+ const locale = useStorage('valaxy-locale', config.value.lang || 'en')
30
48
 
31
49
  // init i18n, by valaxy config
32
50
  const i18n = createI18n({
33
51
  legacy: false,
34
- locale: valaxyConfigRef.value.lang || 'en',
52
+ locale: locale.value,
35
53
  messages,
36
54
  })
37
55
  app.use(i18n)
38
56
 
39
57
  // for dev
40
- if (isDev) {
58
+ if (__DEV__) {
41
59
  import.meta.hot!.on('valaxy:pageHeaders', (payload) => {
42
60
  if (shouldHotReload(payload))
43
61
  router.currentRoute.value.meta.headers = payload.pageHeaders
@@ -3,11 +3,6 @@ import 'vue-router'
3
3
  import type { Post } from 'valaxy'
4
4
  import type { Header } from '../node/markdown'
5
5
 
6
- declare interface Window {
7
- // extend the window
8
- Waline: any
9
- }
10
-
11
6
  // with vite-plugin-md, markdowns can be treat as Vue components
12
7
  declare module '*.md' {
13
8
  import type { DefineComponent } from 'vue'
@@ -28,6 +23,11 @@ declare module '@valaxyjs/config' {
28
23
  export default config
29
24
  }
30
25
 
26
+ declare module '/@valaxyjs/locales' {
27
+ const messages: {}
28
+ export default messages
29
+ }
30
+
31
31
  declare module 'vue-router' {
32
32
  interface RouteMeta {
33
33
  headers: Header[]