valaxy 0.20.6 → 0.21.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.
@@ -1,6 +1,5 @@
1
1
  <script setup lang="ts">
2
2
  import { definePerson, defineWebPage, defineWebSite, useSchemaOrg } from '@unhead/schema-org'
3
- // import { useHead, useSeoMeta } from '@unhead/vue'
4
3
  import { useSeoMeta } from '@unhead/vue'
5
4
 
6
5
  // TODO: add docs to override ValaxyApp
@@ -1,9 +1,10 @@
1
1
  <script lang="ts" setup>
2
2
  import { runContentUpdated, useDecrypt, useFrontmatter } from 'valaxy'
3
- import { defineComponent, h, onMounted, ref } from 'vue'
3
+ import { computed, defineComponent, h, ref } from 'vue'
4
4
 
5
5
  const props = defineProps<{
6
6
  encryptedContent: string
7
+ hint?: string
7
8
  }>()
8
9
 
9
10
  const password = ref('')
@@ -58,11 +59,7 @@ const ValaxyDeprecatedContent = defineComponent({
58
59
  },
59
60
  })
60
61
 
61
- const hasWarning = ref(false)
62
- onMounted(() => {
63
- if (location.protocol !== 'https:')
64
- hasWarning.value = true
65
- })
62
+ const hasWarning = computed(() => location.protocol !== 'https:')
66
63
  </script>
67
64
 
68
65
  <template>
@@ -83,13 +80,17 @@ onMounted(() => {
83
80
  @keyup.enter="decryptContent"
84
81
  >
85
82
  <div
83
+ class="text-gray/70 hover:text-gray transition"
86
84
  cursor-pointer
87
85
  absolute text-2xl
88
86
  i-ri-arrow-right-circle-line right-3
89
- text-gray hover:text-black
90
87
  @click="decryptContent"
91
88
  />
92
89
 
90
+ <div v-if="hint" class="-top-6" absolute text-xs op="50">
91
+ <div v-html="hint" />
92
+ </div>
93
+
93
94
  <div v-if="hasWarning" class="-bottom-6" absolute text-xs op="50">
94
95
  <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API" target="_blank">
95
96
  <span>Web Crypto API</span>
@@ -5,7 +5,11 @@ import valaxyLogoPng from '../assets/images/valaxy-logo.png'
5
5
  <template>
6
6
  <div class="valaxy-logo-container" relative inline-flex justify="center" items="center">
7
7
  <div class="absolute bg-img" />
8
- <img class="fly-animation" w="50" aspect="420/386" m="auto" :src="valaxyLogoPng" alt="Valaxy Logo" z="1">
8
+ <img
9
+ class="fly-animation h-50"
10
+ aspect="420/386" m="auto"
11
+ :src="valaxyLogoPng" alt="Valaxy Logo" z="1"
12
+ >
9
13
  </div>
10
14
  </template>
11
15
 
@@ -11,10 +11,12 @@ export function useValaxyHead() {
11
11
 
12
12
  const fm = useFrontmatter()
13
13
  const siteConfig = useSiteConfig()
14
- const title = computed(() => fm.value[`title_${locale.value}`] || fm.value.title)
14
+ const title = computed<string>(() => fm.value[`title_${locale.value}`] || fm.value.title)
15
15
  useHead({
16
16
  title,
17
- titleTemplate: computed(() => fm.value.titleTemplate || ((title: string) => title ? `${title} - ${siteConfig.value.title}` : siteConfig.value.title)),
17
+ titleTemplate: (title) => {
18
+ return fm.value.titleTemplate || (title ? `${title} - ${siteConfig.value.title}` : siteConfig.value.title)
19
+ },
18
20
  link: [
19
21
  {
20
22
  rel: 'icon',
@@ -23,7 +25,12 @@ export function useValaxyHead() {
23
25
  },
24
26
  ],
25
27
  meta: [
26
- { name: 'description', content: computed(() => siteConfig.value.description) },
28
+ computed(() => {
29
+ return {
30
+ name: 'description',
31
+ content: fm.value.description || siteConfig.value.description,
32
+ }
33
+ }),
27
34
  {
28
35
  name: 'generator',
29
36
  content: `Valaxy ${pkg.version}`,
@@ -47,6 +47,10 @@ export function useActiveAnchor(
47
47
  window.removeEventListener('scroll', onScroll)
48
48
  })
49
49
 
50
+ /**
51
+ * 长目录自动滚动
52
+ * @TODO add e2e test
53
+ */
50
54
  const checkActiveLinkInViewport = () => {
51
55
  const activeLink = prevActiveLink
52
56
  if (!activeLink) {
@@ -54,15 +58,12 @@ export function useActiveAnchor(
54
58
  return
55
59
  }
56
60
 
57
- const top = activeLink.getBoundingClientRect().top
58
- const bottom = activeLink.getBoundingClientRect().bottom
59
-
60
61
  const parentEl = document.querySelector('.yun-aside') as HTMLElement
61
62
  if (parentEl) {
62
- if (top < parentEl.scrollTop)
63
- parentEl.scrollTo({ top: 0, behavior: 'smooth' })
64
- if (bottom > parentEl.offsetHeight + parentEl.scrollTop)
65
- parentEl.scrollTo({ top: bottom + 40, behavior: 'smooth' })
63
+ // 超出
64
+ const top = activeLink.offsetTop + topOffset + 60
65
+ if (top < parentEl.scrollTop || (top > parentEl.offsetHeight + parentEl.scrollTop))
66
+ parentEl.scrollTo({ top, behavior: 'smooth' })
66
67
  }
67
68
  }
68
69
 
package/client/setups.ts CHANGED
@@ -8,7 +8,7 @@ import type { MermaidOptions } from './types'
8
8
  * The context object for the application setup function.
9
9
  *
10
10
  * @zh
11
- * 应用 setup 函数的上下文对象。(包括了 ViteSSG context)
11
+ * 应用 setup 函数的上下文对象。(包括了 `ViteSSGContext`)
12
12
  */
13
13
  export type AppContext = ViteSSGContext
14
14
 
@@ -0,0 +1,7 @@
1
+ # styles/common
2
+
3
+ 公共样式,可由主题作者自行引入。
4
+
5
+ ```ts
6
+ import 'valaxy/client/styles/common/index.scss'
7
+ ```
@@ -0,0 +1,7 @@
1
+ // common
2
+ @use "./code.scss" as *;
3
+ @use "./hamburger.scss" as *;
4
+ @use "./transition.scss" as *;
5
+
6
+ // markdown
7
+ @use "./markdown.scss";
@@ -25,15 +25,15 @@
25
25
 
26
26
  // custom block
27
27
  .custom-block {
28
- margin: 16px 0;
29
-
30
28
  p {
31
29
  margin: 8px 0;
32
30
  line-height: 24px;
33
31
  }
32
+ }
34
33
 
35
- p:first-child {
36
- margin: 0;
34
+ .custom-block div[lang] {
35
+ p {
36
+ margin: 8px 0;
37
37
  }
38
38
  }
39
39
 
@@ -9,13 +9,4 @@ $c-primary: #0078e7 !default;
9
9
  // https://github.com/valaxyjs/css-i18n
10
10
  @use "css-i18n/src/styles/index.scss" as *;
11
11
 
12
- // common
13
- @use "./common/code.scss" as *;
14
- @use "./common/hamburger.scss" as *;
15
- @use "./common/scrollbar.scss" as *;
16
- @use "./common/transition.scss" as *;
17
-
18
- // markdown
19
- @use "./common/markdown.scss";
20
-
21
12
  // components import by yourself