valaxy 0.7.7 → 0.8.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 (47) hide show
  1. package/README.md +4 -0
  2. package/client/README.md +3 -0
  3. package/client/components/ValaxyCopyright.vue +1 -1
  4. package/client/components/ValaxyMd.vue +2 -4
  5. package/client/components/ValaxyOverlay.vue +2 -2
  6. package/client/components/ValaxySidebar.vue +1 -2
  7. package/client/composables/comments/twikoo.ts +25 -1
  8. package/client/composables/comments/waline.ts +33 -23
  9. package/client/composables/{copy-code.ts → features/copy-code.ts} +0 -0
  10. package/client/composables/features/index.ts +1 -0
  11. package/client/composables/index.ts +2 -1
  12. package/client/composables/outline.ts +1 -1
  13. package/client/composables/post.ts +1 -1
  14. package/client/composables/widgets/aplayer.ts +10 -5
  15. package/client/config.ts +4 -1
  16. package/client/index.ts +2 -0
  17. package/client/modules/nprogress.ts +1 -1
  18. package/client/modules/pinia.ts +1 -1
  19. package/client/modules/valaxy.ts +1 -1
  20. package/client/scaffolds/post.md +6 -0
  21. package/client/styles/common/code.scss +1 -1
  22. package/client/styles/common/scrollbar.scss +1 -1
  23. package/client/{types.ts → types/index.ts} +0 -0
  24. package/client/utils/cdn.ts +1 -0
  25. package/client/utils/index.ts +1 -0
  26. package/dist/{chunk-HP2UOVSL.mjs → chunk-ER6SQ4ZW.mjs} +204 -204
  27. package/dist/{chunk-BTP4CLJN.js → chunk-VGABMGJA.js} +203 -203
  28. package/dist/config-60c840d8.d.ts +202 -0
  29. package/dist/node/cli.js +11 -11
  30. package/dist/node/cli.mjs +11 -11
  31. package/dist/node/index.d.ts +140 -15
  32. package/dist/node/index.js +1 -1
  33. package/dist/node/index.mjs +1 -1
  34. package/dist/types/index.d.ts +154 -10
  35. package/index.d.ts +1 -1
  36. package/package.json +14 -8
  37. package/types/config.ts +218 -0
  38. package/types/data.ts +31 -0
  39. package/types/index.ts +3 -0
  40. package/types/posts.ts +133 -0
  41. package/client/app/data.ts +0 -0
  42. package/client/components/ValaxyRightSidebar.vue +0 -73
  43. package/client/components/ValaxyToc.vue +0 -140
  44. package/client/modules/README.md +0 -11
  45. package/client/pages/README.md +0 -20
  46. package/client/shims.d.ts +0 -42
  47. package/dist/index-df14d281.d.ts +0 -462
package/README.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  Read [YunYouJun/valaxy](https://github.com/YunYouJun/valaxy) for more info.
6
6
 
7
+ ## Creating customized templates
8
+
9
+ Learn how to creating customized templates in [here](./docs/en/creating-templates.md)
10
+
7
11
  ## FAQ
8
12
 
9
13
  - `exports`: `src/index.ts` for virtual module
@@ -0,0 +1,3 @@
1
+ # FAQ
2
+
3
+ - use relative path in `valaxy/client` to avoid client/node problem
@@ -51,7 +51,7 @@ const licenseHtml = computed(() => {
51
51
  </template>
52
52
 
53
53
  <style lang="scss">
54
- @use "~/styles/mixins" as *;
54
+ @use "valaxy/client/styles/mixins/index.scss" as *;
55
55
 
56
56
  .post-copyright {
57
57
  font-size: 0.9rem;
@@ -1,10 +1,8 @@
1
1
  <script lang="ts" setup>
2
- import type { Post } from 'valaxy'
3
2
  import { onMounted, ref } from 'vue'
4
3
  import { useI18n } from 'vue-i18n'
5
- import { useAplayer, useCodePen } from '~/composables'
6
- import { useCopyCode } from '~/composables/copy-code'
7
- import { wrapTable } from '~/utils'
4
+ import { useAplayer, useCodePen, useCopyCode, wrapTable } from '..'
5
+ import type { Post } from '../../types'
8
6
 
9
7
  const props = defineProps<{
10
8
  frontmatter: Post
@@ -15,8 +15,8 @@ withDefaults(defineProps<{
15
15
  <style lang="scss">
16
16
  @use "sass:map";
17
17
 
18
- @use "~/styles/vars" as *;
19
- @use "~/styles/mixins" as *;
18
+ @use "valaxy/client/styles/vars" as *;
19
+ @use "valaxy/client/styles/mixins" as *;
20
20
 
21
21
  .va-overlay {
22
22
  background-color: rgba(0, 0, 0, 0.3);
@@ -1,6 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { useLayout } from '~/composables'
3
- import { useAppStore } from '~/stores/app'
2
+ import { useAppStore, useLayout } from '..'
4
3
 
5
4
  const app = useAppStore()
6
5
  const isHome = useLayout('home')
@@ -1,8 +1,32 @@
1
1
  import { isClient, useScriptTag } from '@vueuse/core'
2
+ import { computed } from 'vue'
2
3
  import { useI18n } from 'vue-i18n'
3
4
  import { useRoute } from 'vue-router'
5
+ import { useConfig } from '../..'
4
6
 
7
+ declare global {
8
+ interface Window {
9
+ // extend the window
10
+ twikoo: {
11
+ init: (options: {
12
+ envId: string
13
+ el: string
14
+ } | any) => any
15
+ }
16
+ }
17
+ }
18
+
19
+ /**
20
+ * A simple, safe, free comment system.
21
+ * @public
22
+ * @see https://github.com/imaegoo/twikoo
23
+ * @see https://twikoo.js.org/
24
+ * @param options
25
+ */
5
26
  export function useTwikoo(options: {} = {}) {
27
+ const config = useConfig()
28
+ const cdnPrefix = computed(() => config.value.cdn.prefix)
29
+
6
30
  const route = useRoute()
7
31
  const { locale } = useI18n()
8
32
 
@@ -25,7 +49,7 @@ export function useTwikoo(options: {} = {}) {
25
49
  }
26
50
 
27
51
  // 直接使用 CDN
28
- useScriptTag('//cdn.jsdelivr.net/npm/twikoo@1.5.1/dist/twikoo.all.min.js', () => {
52
+ useScriptTag(`${cdnPrefix.value}twikoo@1.5.1/dist/twikoo.all.min.js`, () => {
29
53
  initTwikoo(options)
30
54
  })
31
55
  }
@@ -1,21 +1,35 @@
1
- import { isClient, useScriptTag } from '@vueuse/core'
2
- import { useHead } from '@vueuse/head'
3
- import { onUnmounted, watch } from 'vue'
1
+ import { isClient } from '@vueuse/core'
2
+ import { onMounted, onUnmounted, watch } from 'vue'
4
3
  import { useI18n } from 'vue-i18n'
5
4
  import { useRoute } from 'vue-router'
6
5
 
7
- export function useWaline(options: {} = {}) {
8
- useHead({
9
- link: [
10
- { rel: 'stylesheet', href: 'https://cdn.jsdelivr.net/npm/@waline/client/dist/waline.css' },
11
- ],
12
- })
6
+ import type { WalineInitOptions, WalineInstance } from '@waline/client'
7
+ import { cdnPrefix } from '../../utils'
8
+
9
+ /**
10
+ * A Simple, Safe Comment System.
11
+ * @public
12
+ * @see https://github.com/walinejs/waline
13
+ * @see https://waline.js.org/
14
+ * @param options
15
+ * @returns
16
+ */
17
+ export function useWaline(options: {} = {}, cdn = cdnPrefix) {
18
+ if (!isClient)
19
+ return
20
+
21
+ // import css
22
+ import('@waline/client/dist/waline.css')
13
23
 
14
24
  const route = useRoute()
15
25
 
16
26
  const { locale } = useI18n()
17
27
 
18
- let waline: any
28
+ let waline: WalineInstance | null | undefined
29
+
30
+ onMounted(() => {
31
+ initWaline(options)
32
+ })
19
33
 
20
34
  /**
21
35
  * init waline
@@ -23,28 +37,24 @@ export function useWaline(options: {} = {}) {
23
37
  * @returns
24
38
  */
25
39
  function initWaline(options: {} = {}) {
26
- if (!isClient)
27
- return
28
-
29
- const defaultOptions = {
40
+ const defaultOptions: WalineInitOptions = {
30
41
  el: '.comment #waline',
42
+ serverURL: '',
31
43
  lang: locale.value,
32
44
  dark: 'html.dark',
33
45
  emoji: [
34
- 'https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/bilibili',
35
- 'https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/qq',
36
- 'https://cdn.jsdelivr.net/gh/walinejs/emojis@1.0.0/weibo',
46
+ `${cdn}@waline/emojis/bilibili/`,
47
+ `${cdn}@waline/emojis/qq/`,
48
+ `${cdn}@waline/emojis/weibo/`,
37
49
  ],
38
50
  path: route.path,
39
51
  }
40
52
  const walineOptions = Object.assign(defaultOptions, options)
41
- return window.Waline.init(walineOptions)
42
- }
43
53
 
44
- // 直接使用 CDN
45
- useScriptTag('//cdn.jsdelivr.net/npm/@waline/client/dist/waline.js', () => {
46
- waline = initWaline(options)
47
- })
54
+ import('@waline/client').then(({ init }) => {
55
+ waline = init(walineOptions)
56
+ })
57
+ }
48
58
 
49
59
  watch(() => route.path, (path) => {
50
60
  if (!waline)
@@ -0,0 +1 @@
1
+ export * from './copy-code'
@@ -5,7 +5,7 @@ export * from './tag'
5
5
 
6
6
  // common
7
7
  export * from './common'
8
- // export * from './features'
8
+ export * from './features'
9
9
  export * from './helper'
10
10
  export * from './dark'
11
11
  export * from './layout'
@@ -13,6 +13,7 @@ export * from './widgets'
13
13
  export * from './locale'
14
14
 
15
15
  export * from './sidebar'
16
+ export * from './outline'
16
17
 
17
18
  // comment
18
19
  export * from './comments'
@@ -1,7 +1,7 @@
1
1
  import type { Ref } from 'vue'
2
2
  import { onMounted, onUnmounted, onUpdated } from 'vue'
3
+ import { throttleAndDebounce } from '../utils'
3
4
  import type { Header } from '../../types'
4
- import { throttleAndDebounce } from '~/utils'
5
5
 
6
6
  interface HeaderWithChildren extends Header {
7
7
  children?: Header[]
@@ -2,8 +2,8 @@ import type { Ref } from 'vue'
2
2
  import { computed } from 'vue'
3
3
  import { useRoute, useRouter } from 'vue-router'
4
4
  import { useI18n } from 'vue-i18n'
5
- import { sortByDate } from '../utils'
6
5
  import type { Post } from '../../types'
6
+ import { sortByDate } from '../utils'
7
7
 
8
8
  export const usePostTitle = (post: Ref<Post>) => {
9
9
  const { locale } = useI18n()
@@ -1,23 +1,28 @@
1
1
  import { useScriptTag } from '@vueuse/core'
2
2
  import { useHead } from '@vueuse/head'
3
+ import { computed } from 'vue'
4
+ import { useConfig } from '../..'
3
5
 
4
6
  /**
5
7
  * use MetingJS and Aplayer
6
- * https://github.com/MoePlayer/APlayer
7
- * https://github.com/metowolf/MetingJS
8
+ * @see https://github.com/MoePlayer/APlayer
9
+ * @see https://github.com/metowolf/MetingJS
8
10
  */
9
11
  export function useAplayer() {
12
+ const config = useConfig()
13
+ const cdnPrefix = computed(() => config.value.cdn.prefix)
14
+
10
15
  useHead({
11
16
  link: [
12
17
  {
13
18
  rel: 'stylesheet',
14
- href: 'https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css',
19
+ href: `${cdnPrefix.value}aplayer/dist/APlayer.min.css`,
15
20
  },
16
21
  ],
17
22
  })
18
23
 
19
24
  // load meting after aplayer
20
- useScriptTag('https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js', () => {
21
- useScriptTag('https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js')
25
+ useScriptTag(`${cdnPrefix.value}aplayer/dist/APlayer.min.js`, () => {
26
+ useScriptTag(`${cdnPrefix.value}meting@2/dist/Meting.min.js`)
22
27
  })
23
28
  }
package/client/config.ts CHANGED
@@ -5,7 +5,10 @@ import valaxyContext from '/@valaxyjs/context'
5
5
  import type { ComputedRef, InjectionKey, Ref } from 'vue'
6
6
  import { computed, inject, readonly, shallowRef } from 'vue'
7
7
  // import type { RouteMeta } from 'vue-router'
8
- import type { PageData, ValaxyConfig } from '../types'
8
+ // fix build caused by pnpm
9
+ // This is likely not portable. A type annotation is necessary.
10
+ // https://github.com/microsoft/TypeScript/issues/42873
11
+ import type { PageData, ValaxyConfig } from 'valaxy/types'
9
12
 
10
13
  /**
11
14
  * parse valaxy config
package/client/index.ts CHANGED
@@ -6,3 +6,5 @@ export * from './stores/app'
6
6
  export * from './utils'
7
7
 
8
8
  export * from './setups'
9
+
10
+ export * from './types'
@@ -1,5 +1,5 @@
1
1
  import NProgress from 'nprogress'
2
- import type { UserModule } from '~/types'
2
+ import type { UserModule } from '../types'
3
3
 
4
4
  export const install: UserModule = ({ isClient, router }) => {
5
5
  if (isClient) {
@@ -1,5 +1,5 @@
1
1
  import { createPinia } from 'pinia'
2
- import type { UserModule } from '~/types'
2
+ import type { UserModule } from '../types'
3
3
 
4
4
  // Setup Pinia
5
5
  // https://pinia.esm.dev/
@@ -15,7 +15,7 @@ import type { PageDataPayload } from '../../types'
15
15
  import { initConfig, valaxyConfigSymbol } from '../config'
16
16
  import { ensureSuffix } from '@antfu/utils'
17
17
 
18
- import type { UserModule } from '~/types'
18
+ import type { UserModule } from 'valaxy/client/types'
19
19
 
20
20
  // @ts-expect-error virtual
21
21
  import messages from '/@valaxyjs/locales'
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: <%=layout%>
3
+ title: <%=title%>
4
+ date: <%=date%>
5
+ ---
6
+
@@ -1,4 +1,4 @@
1
- @use "~/styles/mixins" as *;
1
+ @use "valaxy/client/styles/mixins" as *;
2
2
 
3
3
  @include mobile {
4
4
  .markdown-body {
@@ -1,4 +1,4 @@
1
- @use "~/styles/mixins" as *;
1
+ @use "valaxy/client/styles/mixins" as *;
2
2
 
3
3
  ::-webkit-scrollbar {
4
4
  width: 8px;
File without changes
@@ -0,0 +1 @@
1
+ export const cdnPrefix = 'https://npm.elemecdn.com/'
@@ -1,2 +1,3 @@
1
+ export * from './cdn'
1
2
  export * from './helper'
2
3
  export * from './time'