valaxy 0.14.61 → 0.15.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 (51) hide show
  1. package/client/components/ValaxyMd.vue +2 -0
  2. package/client/composables/back.ts +18 -0
  3. package/client/composables/categories.ts +0 -1
  4. package/client/composables/codeGroups.ts +52 -0
  5. package/client/composables/common.ts +0 -1
  6. package/client/composables/decrypt.ts +0 -1
  7. package/client/composables/helper.ts +0 -1
  8. package/client/composables/index.ts +1 -0
  9. package/client/composables/outline/headers.ts +0 -2
  10. package/client/composables/post.ts +0 -4
  11. package/client/composables/tags.ts +0 -1
  12. package/client/config.ts +0 -5
  13. package/client/layouts/404.vue +21 -23
  14. package/client/stores/app.ts +5 -0
  15. package/client/styles/common/code.scss +51 -51
  16. package/client/styles/common/markdown.scss +90 -36
  17. package/client/styles/components/code-group.scss +85 -0
  18. package/client/styles/components/custom-block.scss +190 -0
  19. package/client/styles/css-vars/borders.css +24 -0
  20. package/client/styles/css-vars/function.css +51 -0
  21. package/client/styles/css-vars/palette.css +83 -0
  22. package/client/styles/css-vars.scss +31 -2
  23. package/client/styles/global/reset.scss +1 -1
  24. package/client/styles/index.scss +2 -1
  25. package/client/styles/palette.scss +4 -4
  26. package/client/styles/vars.scss +3 -3
  27. package/client/utils/helper.ts +0 -1
  28. package/client/utils/time.ts +0 -1
  29. package/client/utils/wrap.ts +0 -1
  30. package/dist/chunk-DMHUSKCP.cjs +128 -0
  31. package/dist/chunk-M4Y54B6H.mjs +2 -0
  32. package/dist/chunk-MHVZJPKO.cjs +1 -0
  33. package/dist/chunk-MMTKTJH7.mjs +129 -0
  34. package/dist/{config-42c9d78a.d.ts → config-9f7e02a4.d.ts} +2 -12
  35. package/dist/node/cli.cjs +1 -1
  36. package/dist/node/cli.mjs +2 -1
  37. package/dist/node/index.cjs +1 -1
  38. package/dist/node/index.d.cts +7 -19
  39. package/dist/node/index.d.ts +7 -19
  40. package/dist/node/index.mjs +2 -1
  41. package/dist/types/index.cjs +1 -1
  42. package/dist/types/index.d.cts +3 -1
  43. package/dist/types/index.d.ts +3 -1
  44. package/dist/types/index.mjs +2 -0
  45. package/package.json +35 -31
  46. package/types/config.ts +1 -1
  47. package/types/{default-theme.ts → default-theme.d.ts} +1 -2
  48. package/types/index.ts +2 -2
  49. package/client/styles/common/custom-blocks.scss +0 -93
  50. package/dist/chunk-NERYRW7R.mjs +0 -129
  51. package/dist/chunk-QA3AARSF.cjs +0 -129
@@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n'
4
4
  import { onContentUpdated, runContentUpdated, useAplayer, useCodePen, useCopyCode, useMediumZoom, wrapTable } from 'valaxy'
5
5
  import type { Post } from 'valaxy'
6
6
  import { useVanillaLazyLoad } from '../composables/features/vanilla-lazyload'
7
+ import { useCodeGroups } from '../composables/codeGroups'
7
8
 
8
9
  const props = defineProps<{
9
10
  frontmatter: Post
@@ -29,6 +30,7 @@ if (props.frontmatter.codepen)
29
30
  useCodePen()
30
31
 
31
32
  useCopyCode()
33
+ useCodeGroups()
32
34
 
33
35
  if (typeof props.frontmatter.medium_zoom === 'undefined' || props.frontmatter.medium_zoom)
34
36
  useMediumZoom()
@@ -0,0 +1,18 @@
1
+ import { useRouter } from 'vue-router'
2
+
3
+ /**
4
+ * back to previous page or home page
5
+ */
6
+ export function useBack() {
7
+ const router = useRouter()
8
+
9
+ function back() {
10
+ if (document.referrer && document.referrer !== location.href)
11
+ router.back()
12
+ else
13
+ router.push('/')
14
+ }
15
+ return {
16
+ back,
17
+ }
18
+ }
@@ -40,7 +40,6 @@ export function isCategoryList(category: any): category is CategoryList {
40
40
  * }
41
41
  * ]
42
42
  * }
43
- * @returns
44
43
  */
45
44
  export function useCategories(category?: MaybeRef<string>, posts: Post[] = []) {
46
45
  return computed(() => {
@@ -0,0 +1,52 @@
1
+ import { onContentUpdated } from 'valaxy'
2
+ import { isClient } from '@vueuse/core'
3
+
4
+ export function useCodeGroups() {
5
+ if (import.meta.env.DEV) {
6
+ onContentUpdated(() => {
7
+ document.querySelectorAll('.vp-code-group > .blocks').forEach((el) => {
8
+ Array.from(el.children).forEach((child) => {
9
+ child.classList.remove('active')
10
+ })
11
+ el.children[0].classList.add('active')
12
+ })
13
+ })
14
+ }
15
+
16
+ if (isClient) {
17
+ window.addEventListener('click', (e) => {
18
+ const el = e.target as HTMLInputElement
19
+
20
+ if (el.matches('.vp-code-group input')) {
21
+ // input <- .tabs <- .vp-code-group
22
+ const group = el.parentElement?.parentElement
23
+ if (!group)
24
+ return
25
+
26
+ const i = Array.from(group.querySelectorAll('input')).indexOf(el)
27
+ if (i < 0)
28
+ return
29
+
30
+ const blocks = group.querySelector('.blocks')
31
+ if (!blocks)
32
+ return
33
+
34
+ const current = Array.from(blocks.children).find(child =>
35
+ child.classList.contains('active'),
36
+ )
37
+ if (!current)
38
+ return
39
+
40
+ const next = blocks.children[i]
41
+ if (!next || current === next)
42
+ return
43
+
44
+ current.classList.remove('active')
45
+ next.classList.add('active')
46
+
47
+ const label = group?.querySelector(`label[for="${el.id}"]`)
48
+ label?.scrollIntoView({ block: 'nearest' })
49
+ }
50
+ })
51
+ }
52
+ }
@@ -14,7 +14,6 @@ export function useFrontmatter() {
14
14
 
15
15
  /**
16
16
  * inject pageData
17
- * @returns
18
17
  */
19
18
  export function useData(): PageData {
20
19
  const value = inject<PageData>('pageData', {} as any)
@@ -3,7 +3,6 @@ import { useSiteConfig } from 'valaxy'
3
3
  /**
4
4
  * @see https://developer.mozilla.org/zh-CN/docs/Web/API/SubtleCrypto/deriveKey#pbkdf2_2
5
5
  * @param password
6
- * @returns
7
6
  */
8
7
  export function getKeyMaterial(password: string) {
9
8
  const enc = new TextEncoder()
@@ -5,7 +5,6 @@ import { ref } from 'vue'
5
5
  /**
6
6
  * trigger show invisible element
7
7
  * @param target
8
- * @returns
9
8
  */
10
9
  export function useInvisibleElement(target: Ref<HTMLElement | undefined>) {
11
10
  const isVisible = ref(false)
@@ -17,4 +17,5 @@ export * from './outline'
17
17
  export * from './body-scroll-lock'
18
18
 
19
19
  // utils
20
+ export * from './back'
20
21
  export * from './decrypt'
@@ -64,7 +64,6 @@ function addToParent(
64
64
 
65
65
  /**
66
66
  * export headers & handleClick to generate outline
67
- * @returns
68
67
  */
69
68
  export function useOutline() {
70
69
  const frontmatter = useFrontmatter()
@@ -104,7 +103,6 @@ export function useOutline() {
104
103
 
105
104
  /**
106
105
  * get headers from document directly
107
- * @returns
108
106
  */
109
107
  export function getHeaders(range: Exclude<DefaultTheme.Config['outline'], false>) {
110
108
  const headers = Array.from(document.querySelectorAll('.markdown-body :where(h1,h2,h3,h4,h5,h6)'))
@@ -16,7 +16,6 @@ export function usePostTitle(post: ComputedRef<Post>) {
16
16
 
17
17
  /**
18
18
  * get all page in 'pages' folder
19
- * @returns
20
19
  */
21
20
  export function usePageList() {
22
21
  return computed<Post[]>(() => {
@@ -37,8 +36,6 @@ export function usePageList() {
37
36
  /**
38
37
  * get post list in 'pages/posts' folder
39
38
  * todo: use vue provide/inject to global
40
- * @param params
41
- * @returns
42
39
  */
43
40
  export function usePostList(params: {
44
41
  type?: string
@@ -67,7 +64,6 @@ export function usePostList(params: {
67
64
  /**
68
65
  * get prev and next post
69
66
  * @param path
70
- * @returns
71
67
  */
72
68
  export function usePrevNext(path?: string) {
73
69
  const route = useRoute()
@@ -9,7 +9,6 @@ export type Tags = Map<string, {
9
9
  /**
10
10
  * get tag map
11
11
  * [tagName]: count
12
- * @returns
13
12
  */
14
13
  export function useTags() {
15
14
  const site = useSiteStore()
package/client/config.ts CHANGED
@@ -15,7 +15,6 @@ import type { DefaultTheme, ValaxyConfig } from 'valaxy/types'
15
15
  /**
16
16
  * parse valaxy config
17
17
  * @param data
18
- * @returns
19
18
  */
20
19
  function parse<T = any>(data: string): T {
21
20
  const parsed = JSON.parse(data)
@@ -55,7 +54,6 @@ export function initContext() {
55
54
  /**
56
55
  * get valaxy config
57
56
  * @public
58
- * @returns
59
57
  */
60
58
  export function useValaxyConfig<ThemeConfig = DefaultTheme.Config>() {
61
59
  const config = inject<ComputedRef<ValaxyConfig<ThemeConfig>>>(valaxyConfigSymbol)
@@ -67,7 +65,6 @@ export function useValaxyConfig<ThemeConfig = DefaultTheme.Config>() {
67
65
  /**
68
66
  * alias for useSite
69
67
  * @public
70
- * @returns
71
68
  */
72
69
  export function useConfig<ThemeConfig = DefaultTheme.Config>() {
73
70
  return useValaxyConfig<ThemeConfig>()
@@ -76,7 +73,6 @@ export function useConfig<ThemeConfig = DefaultTheme.Config>() {
76
73
  /**
77
74
  * get valaxy config
78
75
  * @public
79
- * @returns
80
76
  */
81
77
  export function useSiteConfig<ThemeConfig = DefaultTheme.Config>() {
82
78
  const config = useValaxyConfig<ThemeConfig>()
@@ -88,7 +84,6 @@ export function useSiteConfig<ThemeConfig = DefaultTheme.Config>() {
88
84
  * if you want to: import { useThemeConfig } from 'valaxy'
89
85
  * you need pass themeConfig by yourself
90
86
  * @internal
91
- * @returns
92
87
  */
93
88
  export function useThemeConfig<ThemeConfig = DefaultTheme.Config>() {
94
89
  const config = useValaxyConfig<ThemeConfig>()
@@ -1,33 +1,31 @@
1
1
  <script setup lang="ts">
2
- import { useRouter } from 'vue-router'
3
2
  import { useI18n } from 'vue-i18n'
3
+ import { useBack } from '..'
4
4
 
5
- const router = useRouter()
6
5
  const { t } = useI18n()
7
-
8
- function back() {
9
- if (document.referrer)
10
- router.back()
11
- else
12
- router.push('/')
13
- }
6
+ const { back } = useBack()
14
7
  </script>
15
8
 
16
9
  <template>
17
- <main class="va-main" text="center">
18
- <div p="10" text="yellow-600">
19
- <div text-6xl>
20
- <div i-ri-alarm-warning-line inline-block />
21
- </div>
22
- <div m="2" text="xl">
23
- {{ t('not-found') }}
24
- </div>
25
- <router-view />
26
- <div>
27
- <button class="btn rounded-full" p="x-6 y-2" text="sm" m="3 t8" :title="t('button.back')" @click="back">
28
- {{ t('button.back') }}
29
- </button>
30
- </div>
10
+ <main class="va-main w-full h-screen" text="center" flex="~ col" justify="center" items="center">
11
+ <div class="not-found" title="404" font="mono">
12
+ 404
13
+ </div>
14
+
15
+ <router-view />
16
+
17
+ <div>
18
+ <button class="btn rounded-full" p="x-6 y-2" text="sm" m="3 t8" :title="t('button.back')" @click="back">
19
+ {{ t('button.back') }}
20
+ </button>
31
21
  </div>
32
22
  </main>
33
23
  </template>
24
+
25
+ <style lang="scss" scoped>
26
+ // inspired by https://codepen.io/pgalor/pen/OeRWJQ
27
+ .not-found {
28
+ font-size: 10rem;
29
+ text-shadow: 0 5px 10px rgba(0,0,0,.25), 0 20px 20px rgba(0,0,0,.15);
30
+ }
31
+ </style>
@@ -1,12 +1,17 @@
1
1
  import { acceptHMRUpdate, defineStore } from 'pinia'
2
2
  import { useToggle } from '@vueuse/core'
3
+ import { ref } from 'vue'
3
4
 
4
5
  export const useAppStore = defineStore('app', () => {
6
+ const showLoading = ref(true)
7
+
5
8
  const [isSidebarOpen, toggleSidebar] = useToggle(false)
6
9
  // right sidebar with toc
7
10
  const [isRightSidebarOpen, toggleRightSidebar] = useToggle(false)
8
11
 
9
12
  return {
13
+ showLoading,
14
+
10
15
  isSidebarOpen,
11
16
  toggleSidebar,
12
17
 
@@ -41,64 +41,64 @@ html:not(.dark) .vp-code-dark {
41
41
  position: relative;
42
42
  background-color: var(--va-code-block-bg);
43
43
  overflow-x: auto;
44
-
45
- code {
46
- padding: 0 24px;
47
- line-height: var(--va-code-line-height);
48
- font-size: var(--va-code-font-size);
49
- color: var(--va-code-block-color);
50
- transition: color 0.5s;
51
- width: fit-content;
52
-
53
- text-align: left;
54
- white-space: pre;
55
- word-spacing: normal;
56
- word-break: normal;
57
- word-wrap: normal;
58
- -moz-tab-size: 4;
59
- -o-tab-size: 4;
60
- tab-size: 4;
61
- -webkit-hyphens: none;
62
- -moz-hyphens: none;
63
- -ms-hyphens: none;
64
- hyphens: none;
65
- }
66
-
67
- pre {
68
- position: relative;
69
- z-index: 1;
70
- margin: 0;
71
- padding: 1rem 0;
72
- background: transparent;
73
- overflow-x: auto;
74
-
75
- // expand
76
- code {
77
- display: block;
78
- }
79
- }
80
44
  }
81
45
  }
82
46
 
83
- // marker
84
47
  .markdown-body {
85
- .highlight-lines {
86
- position: absolute;
87
- top: 0;
88
- bottom: 0;
89
- left: 0;
90
- padding: 16px 0;
91
- width: 100%;
48
+ [class*='language-'] pre,
49
+ [class*='language-'] code {
50
+ /*rtl:ignore*/
51
+ direction: ltr;
52
+ /*rtl:ignore*/
53
+ text-align: left;
54
+ white-space: pre;
55
+ word-spacing: normal;
56
+ word-break: normal;
57
+ word-wrap: normal;
58
+ -moz-tab-size: 4;
59
+ -o-tab-size: 4;
60
+ tab-size: 4;
61
+ -webkit-hyphens: none;
62
+ -moz-hyphens: none;
63
+ -ms-hyphens: none;
64
+ hyphens: none;
65
+ }
66
+
67
+ [class*='language-'] pre {
68
+ position: relative;
69
+ z-index: 1;
70
+ margin: 0;
71
+ padding: 20px 0;
72
+ background: transparent;
73
+ overflow-x: auto;
74
+ }
75
+
76
+ [class*='language-'] code {
77
+ display: block;
78
+ padding: 0 24px;
79
+ width: fit-content;
80
+ min-width: 100%;
92
81
  line-height: var(--va-code-line-height);
93
- font-family: var(--va-font-mono);
94
82
  font-size: var(--va-code-font-size);
95
- user-select: none;
96
- overflow: hidden;
83
+ color: var(--va-code-block-color);
84
+ transition: color 0.5s;
85
+ }
97
86
 
98
- .highlighted {
99
- background-color: var(--va-code-line-highlight-color);
100
- transition: background-color 0.5s;
101
- }
87
+ [class*='language-'] code .highlighted {
88
+ background-color: var(--va-code-line-highlight-color);
89
+ transition: background-color 0.5s;
90
+ margin: 0 -24px;
91
+ padding: 0 24px;
92
+ width: calc(100% + 2 * 24px);
93
+ display: inline-block;
94
+ }
95
+
96
+ [class*='language-'] code .highlighted.error {
97
+ background-color: var(--va-code-line-error-color);
98
+ }
99
+
100
+ [class*='language-'] code .highlighted.warning {
101
+ background-color: var(--va-code-line-warning-color);
102
102
  }
103
103
 
104
104
  // copy
@@ -1,43 +1,17 @@
1
1
  @use "sass:map";
2
2
 
3
- // for anchor
4
- h1:hover .header-anchor,
5
- h1:focus .header-anchor,
6
- h2:hover .header-anchor,
7
- h2:focus .header-anchor,
8
- h3:hover .header-anchor,
9
- h3:focus .header-anchor,
10
- h4:hover .header-anchor,
11
- h4:focus .header-anchor,
12
- h5:hover .header-anchor,
13
- h5:focus .header-anchor,
14
- h6:hover .header-anchor,
15
- h6:focus .header-anchor {
16
- visibility: visible;
17
- opacity: 1;
18
- }
19
-
20
- a.header-anchor {
21
- float: left;
22
- margin-top: 0.125em;
23
- margin-left: -0.87em;
24
- padding-right: 0.23em;
25
- font-size: 0.85em;
26
- visibility: hidden;
27
- opacity: 0;
28
- transition: opacity var(--va-transition-duration);
29
-
30
- &::before {
31
- content: none;
3
+ .markdown-body {
4
+ h1,
5
+ h2,
6
+ h3,
7
+ h4,
8
+ h5,
9
+ h6 {
10
+ position: relative;
11
+ font-weight: 600;
12
+ outline: none;
32
13
  }
33
- }
34
14
 
35
- a.header-anchor:hover,
36
- a.header-anchor:focus {
37
- text-decoration: none;
38
- }
39
-
40
- .markdown-body {
41
15
  figure {
42
16
  text-align: center;
43
17
  }
@@ -48,4 +22,84 @@ a.header-anchor:focus {
48
22
  height: 1px;
49
23
  }
50
24
  }
25
+
26
+ // custom block
27
+ .custom-block {
28
+ margin: 16px 0;
29
+
30
+ p {
31
+ margin: 8px 0;
32
+ line-height: 24px;
33
+ }
34
+
35
+ p:first-child {
36
+ margin: 0;
37
+ }
38
+ }
39
+
40
+ .custom-block div[class*='language-'] {
41
+ margin: 8px 0;
42
+ border-radius: 8px;
43
+ }
44
+
45
+ .custom-block div[class*='language-'] code {
46
+ font-weight: 400;
47
+ background-color: transparent;
48
+ }
49
+
50
+ .custom-block .vp-code-group .tabs {
51
+ margin: 0;
52
+ border-radius: 8px 8px 0 0;
53
+ }
54
+ }
55
+
56
+
57
+ // header-anchor
58
+ .markdown-body {
59
+ .header-anchor {
60
+ position: absolute;
61
+ top: 0;
62
+ left: 0;
63
+ margin-left: -0.87em;
64
+ font-weight: 500;
65
+ user-select: none;
66
+ opacity: 0;
67
+ text-decoration: none;
68
+ transition:
69
+ color 0.25s,
70
+ opacity 0.25s;
71
+ }
72
+
73
+ .header-anchor:before {
74
+ content: var(--va-header-anchor-symbol, '#');
75
+
76
+ &:hover {
77
+ text-decoration: none;
78
+ }
79
+ }
80
+
81
+ h1:hover .header-anchor,
82
+ h1 .header-anchor:focus,
83
+ h2:hover .header-anchor,
84
+ h2 .header-anchor:focus,
85
+ h3:hover .header-anchor,
86
+ h3 .header-anchor:focus,
87
+ h4:hover .header-anchor,
88
+ h4 .header-anchor:focus,
89
+ h5:hover .header-anchor,
90
+ h5 .header-anchor:focus,
91
+ h6:hover .header-anchor,
92
+ h6 .header-anchor:focus {
93
+ opacity: 1;
94
+ }
51
95
  }
96
+
97
+
98
+ @media (min-width: 768px) {
99
+ .markdown-body h1 {
100
+ letter-spacing: -0.02em;
101
+ line-height: 40px;
102
+ font-size: 32px;
103
+ }
104
+ }
105
+
@@ -0,0 +1,85 @@
1
+ .vp-code-group {
2
+ margin-top: 16px;
3
+ }
4
+
5
+ .vp-code-group .tabs {
6
+ position: relative;
7
+ display: flex;
8
+ margin-right: -24px;
9
+ margin-left: -24px;
10
+ padding: 0 12px;
11
+ background-color: var(--va-code-tab-bg);
12
+ overflow-x: auto;
13
+ overflow-y: hidden;
14
+ box-shadow: inset 0 -1px var(--va-code-tab-divider);
15
+ }
16
+
17
+ @media (min-width: 640px) {
18
+ .vp-code-group .tabs {
19
+ margin-right: 0;
20
+ margin-left: 0;
21
+ border-radius: 8px 8px 0 0;
22
+ }
23
+ }
24
+
25
+ .vp-code-group .tabs input {
26
+ position: fixed;
27
+ opacity: 0;
28
+ pointer-events: none;
29
+ }
30
+
31
+ .vp-code-group .tabs label {
32
+ position: relative;
33
+ display: inline-block;
34
+ border-bottom: 1px solid transparent;
35
+ padding: 0 12px;
36
+ line-height: 48px;
37
+ font-size: 14px;
38
+ font-weight: 500;
39
+ color: var(--va-code-tab-text-color);
40
+ white-space: nowrap;
41
+ cursor: pointer;
42
+ transition: color 0.25s;
43
+ }
44
+
45
+ .vp-code-group .tabs label::after {
46
+ position: absolute;
47
+ right: 8px;
48
+ bottom: -1px;
49
+ left: 8px;
50
+ z-index: 1;
51
+ height: 2px;
52
+ border-radius: 2px;
53
+ content: '';
54
+ background-color: transparent;
55
+ transition: background-color 0.25s;
56
+ }
57
+
58
+ .vp-code-group label:hover {
59
+ color: var(--va-code-tab-hover-text-color);
60
+ }
61
+
62
+ .vp-code-group input:checked + label {
63
+ color: var(--va-code-tab-active-text-color);
64
+ }
65
+
66
+ .vp-code-group input:checked + label::after {
67
+ background-color: var(--va-code-tab-active-bar-color);
68
+ }
69
+
70
+ .vp-code-group div[class*='language-'],
71
+ .vp-block {
72
+ display: none;
73
+ margin-top: 0 !important;
74
+ border-top-left-radius: 0 !important;
75
+ border-top-right-radius: 0 !important;
76
+ }
77
+
78
+ .vp-code-group div[class*='language-'].active,
79
+ .vp-block.active {
80
+ display: block;
81
+ }
82
+
83
+ .vp-block {
84
+ padding: 20px 24px;
85
+ }