valaxy 0.14.7 → 0.14.9
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.
- package/client/components/ValaxyMd.vue +20 -1
- package/client/composables/common.ts +1 -1
- package/client/composables/locale.ts +6 -0
- package/client/composables/post.ts +1 -1
- package/client/locales/en.yml +1 -0
- package/client/locales/zh-CN.yml +1 -0
- package/client/modules/valaxy.ts +4 -6
- package/dist/{chunk-DM5WHL52.cjs → chunk-B2F42O6L.cjs} +17 -17
- package/dist/{chunk-3UYCMC4D.mjs → chunk-Y63W27CX.mjs} +17 -17
- package/dist/node/cli.cjs +1 -1
- package/dist/node/cli.mjs +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/types/index.d.ts +10 -0
- package/package.json +16 -16
- package/types/posts.ts +11 -0
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import type { Ref } from 'vue'
|
|
3
|
-
import { inject, onMounted, ref } from 'vue'
|
|
3
|
+
import { computed, inject, onMounted, ref } from 'vue'
|
|
4
4
|
import { useI18n } from 'vue-i18n'
|
|
5
5
|
import { useAplayer, useCodePen, useCopyCode, useMediumZoom, wrapTable } from 'valaxy'
|
|
6
6
|
import type { Post } from 'valaxy'
|
|
7
7
|
|
|
8
|
+
import dayjs from 'dayjs'
|
|
9
|
+
import relativeTime from 'dayjs/plugin/relativeTime'
|
|
8
10
|
const props = defineProps<{
|
|
9
11
|
frontmatter: Post
|
|
10
12
|
excerpt?: string
|
|
11
13
|
}>()
|
|
12
14
|
|
|
15
|
+
dayjs.extend(relativeTime)
|
|
16
|
+
|
|
13
17
|
const onContentUpdated = inject('onContentUpdated') as Ref<() => void>
|
|
14
18
|
|
|
15
19
|
const { t } = useI18n()
|
|
@@ -35,11 +39,26 @@ useCopyCode()
|
|
|
35
39
|
|
|
36
40
|
if (typeof props.frontmatter.medium_zoom === 'undefined' || props.frontmatter.medium_zoom)
|
|
37
41
|
useMediumZoom()
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* when the post is updated more than 30 days ago, show a warning
|
|
45
|
+
* default 30 days, you can set `time_warning` in frontmatter to change it
|
|
46
|
+
*/
|
|
47
|
+
const time_warning = computed(() => {
|
|
48
|
+
const diff = dayjs().valueOf() - dayjs(props.frontmatter.updated).valueOf()
|
|
49
|
+
if (typeof props.frontmatter.time_warning === 'number')
|
|
50
|
+
return diff > props.frontmatter.time_warning
|
|
51
|
+
else
|
|
52
|
+
return props.frontmatter.time_warning || diff > 30 * 24 * 60 * 60 * 1000
|
|
53
|
+
})
|
|
38
54
|
</script>
|
|
39
55
|
|
|
40
56
|
<template>
|
|
41
57
|
<Transition appear>
|
|
42
58
|
<article v-if="$slots.default" :class="frontmatter.markdown !== false && 'markdown-body'">
|
|
59
|
+
<blockquote v-if="time_warning" op="80">
|
|
60
|
+
{{ t('post.time_warning', { ago: dayjs(frontmatter.updated).fromNow() }) }}
|
|
61
|
+
</blockquote>
|
|
43
62
|
<slot ref="content" @vnode-updated="updateDom" />
|
|
44
63
|
|
|
45
64
|
<div text="center">
|
|
@@ -2,7 +2,7 @@ import { useRoute } from 'vue-router'
|
|
|
2
2
|
import { computed, inject } from 'vue'
|
|
3
3
|
import { isClient } from '@vueuse/core'
|
|
4
4
|
|
|
5
|
-
import type { PageData, Post } from '
|
|
5
|
+
import type { PageData, Post } from 'valaxy/types'
|
|
6
6
|
import { useSiteConfig } from '../config'
|
|
7
7
|
|
|
8
8
|
export function useFrontmatter() {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { isClient, useStorage } from '@vueuse/core'
|
|
2
2
|
import { useI18n } from 'vue-i18n'
|
|
3
|
+
import dayjs from 'dayjs'
|
|
4
|
+
import 'dayjs/locale/zh-cn'
|
|
3
5
|
|
|
4
6
|
export const useLocale = () => {
|
|
5
7
|
const { availableLocales, locale } = useI18n()
|
|
6
8
|
const lang = useStorage('valaxy-locale', locale.value)
|
|
9
|
+
dayjs.locale(lang.value.toLowerCase())
|
|
7
10
|
|
|
8
11
|
const toggleLocales = () => {
|
|
9
12
|
// change to some real logic
|
|
@@ -13,6 +16,9 @@ export const useLocale = () => {
|
|
|
13
16
|
// for localStorage
|
|
14
17
|
lang.value = locale.value
|
|
15
18
|
|
|
19
|
+
// set dayjs locale
|
|
20
|
+
dayjs.locale(lang.value.toLowerCase())
|
|
21
|
+
|
|
16
22
|
if (isClient)
|
|
17
23
|
document.documentElement.setAttribute('lang', locale.value)
|
|
18
24
|
}
|
|
@@ -26,7 +26,7 @@ export function usePageList() {
|
|
|
26
26
|
.filter(i => i.meta.frontmatter)
|
|
27
27
|
.filter(i => i.path && !excludePages.includes(i.path))
|
|
28
28
|
.map((i) => {
|
|
29
|
-
return Object.assign({ path: i.path, excerpt: i.meta.excerpt }, i.meta.frontmatter)
|
|
29
|
+
return Object.assign({ path: i.path, excerpt: i.meta.excerpt }, i.meta.frontmatter) as Post
|
|
30
30
|
})
|
|
31
31
|
return routes
|
|
32
32
|
})
|
package/client/locales/en.yml
CHANGED
package/client/locales/zh-CN.yml
CHANGED
package/client/modules/valaxy.ts
CHANGED
|
@@ -11,14 +11,12 @@ import { createI18n } from 'vue-i18n'
|
|
|
11
11
|
import { useStorage } from '@vueuse/core'
|
|
12
12
|
|
|
13
13
|
import type { Router } from 'vue-router'
|
|
14
|
-
import type { PageDataPayload } from '../../types'
|
|
15
|
-
import { initValaxyConfig, valaxyConfigSymbol } from '../config'
|
|
16
14
|
import { ensureSuffix } from '@antfu/utils'
|
|
17
|
-
|
|
18
15
|
import type { UserModule } from 'valaxy/client/types'
|
|
19
|
-
|
|
16
|
+
import type { PageDataPayload } from '../../types'
|
|
17
|
+
import { initValaxyConfig, valaxyConfigSymbol } from '../config'
|
|
20
18
|
// @ts-expect-error virtual
|
|
21
|
-
import
|
|
19
|
+
import valaxyMessages from '/@valaxyjs/locales'
|
|
22
20
|
|
|
23
21
|
// Import i18n resources
|
|
24
22
|
// https://vitejs.dev/guide/features.html#glob-import
|
|
@@ -54,7 +52,7 @@ export const install: UserModule = ({ app, router }) => {
|
|
|
54
52
|
const i18n = createI18n({
|
|
55
53
|
legacy: false,
|
|
56
54
|
locale: locale.value,
|
|
57
|
-
messages,
|
|
55
|
+
messages: valaxyMessages,
|
|
58
56
|
})
|
|
59
57
|
app.use(i18n)
|
|
60
58
|
|