valaxy 0.19.9 → 0.19.11
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/ValaxyApp.vue +3 -0
- package/client/components/ValaxyFootnoteTooltip.vue +19 -0
- package/client/composables/collections.ts +28 -0
- package/client/composables/common.ts +21 -4
- package/client/composables/dark.ts +0 -2
- package/client/composables/global.ts +16 -0
- package/client/composables/index.ts +1 -0
- package/client/define/collection.ts +27 -0
- package/client/define/index.ts +1 -0
- package/client/index.ts +3 -0
- package/client/modules/floating-vue.ts +10 -0
- package/client/modules/valaxy.ts +8 -7
- package/client/setup/main.ts +2 -0
- package/client/styles/css/css-vars.css +1 -1
- package/client/styles/palette.scss +2 -1
- package/client/utils/time.ts +5 -6
- package/dist/chunk-6H6IDGZO.mjs +157 -0
- package/dist/chunk-ZYUVBLR3.cjs +156 -0
- package/dist/{config-_Vh4V6Lh.d.cts → config-BNXiUUii.d.cts} +5 -5
- package/dist/{config-_Vh4V6Lh.d.ts → config-BNXiUUii.d.ts} +5 -5
- package/dist/node/cli/index.cjs +1 -1
- package/dist/node/cli/index.mjs +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +23 -2
- package/dist/node/index.d.ts +23 -2
- package/dist/node/index.mjs +1 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.mjs +1 -1
- package/package.json +37 -31
- package/types/config.ts +6 -0
- package/types/frontmatter/page.ts +0 -6
- package/dist/chunk-ELKBAUEC.cjs +0 -156
- package/dist/chunk-MVWDJMOK.mjs +0 -157
- /package/dist/{chunk-FDUDFMUS.mjs → chunk-LIAYL4DV.mjs} +0 -0
- /package/dist/{chunk-635QRI6N.cjs → chunk-LUUQ46JJ.cjs} +0 -0
|
@@ -17,6 +17,7 @@ import { definePerson, defineWebPage, defineWebSite, useSchemaOrg } from '@unhea
|
|
|
17
17
|
// they will be rendered correctly in the html results with vite-ssg
|
|
18
18
|
import { useSiteConfig } from '../config'
|
|
19
19
|
import { useFrontmatter } from '../composables'
|
|
20
|
+
import { useTimezone } from '../composables/global'
|
|
20
21
|
import ValaxyAddons from './ValaxyAddons.vue'
|
|
21
22
|
|
|
22
23
|
// <link rel="apple-touch-icon" href="/pwa-192x192.png">
|
|
@@ -96,6 +97,8 @@ useSchemaOrg([
|
|
|
96
97
|
}),
|
|
97
98
|
defineWebPage(),
|
|
98
99
|
])
|
|
100
|
+
|
|
101
|
+
useTimezone()
|
|
99
102
|
</script>
|
|
100
103
|
|
|
101
104
|
<template>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { PopperWrapper } from 'floating-vue'
|
|
3
|
+
|
|
4
|
+
const Component = ({
|
|
5
|
+
...PopperWrapper,
|
|
6
|
+
name: 'ValaxyFootnoteTooltip',
|
|
7
|
+
vPopperTheme: 'tooltip',
|
|
8
|
+
}) as unknown as typeof PopperWrapper
|
|
9
|
+
|
|
10
|
+
export default Component
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<style scoped>
|
|
14
|
+
@import 'floating-vue/dist/style.css';
|
|
15
|
+
|
|
16
|
+
div .v-popper {
|
|
17
|
+
display: inline
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ref } from 'vue'
|
|
2
|
+
import type { CollectionConfig } from '../define'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Composable for Collections
|
|
6
|
+
* /collections/:collectionId/:slug
|
|
7
|
+
* @example /collections/love-letters/1
|
|
8
|
+
*/
|
|
9
|
+
export function useCollections() {
|
|
10
|
+
// TODO
|
|
11
|
+
|
|
12
|
+
const collections = ref<CollectionConfig[]>([
|
|
13
|
+
{
|
|
14
|
+
id: 'i-and-she',
|
|
15
|
+
name: 'I and She',
|
|
16
|
+
description: 'Love letters from the past',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: 'love-and-peace',
|
|
20
|
+
name: '爱与和平',
|
|
21
|
+
description: 'Recipes for a good life',
|
|
22
|
+
},
|
|
23
|
+
])
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
collections,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -2,14 +2,31 @@ 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,
|
|
5
|
+
import type { PageData, PostFrontMatter } from 'valaxy/types'
|
|
6
6
|
import { useSiteConfig } from '../config'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Get `route.meta.frontmatter` from your markdown file
|
|
10
|
+
* @example
|
|
11
|
+
* ```md
|
|
12
|
+
* ---
|
|
13
|
+
* title: Hello World
|
|
14
|
+
* ---
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* const fm = useFrontmatter()
|
|
19
|
+
* console.log(fm.value.title)
|
|
20
|
+
*
|
|
21
|
+
* const fm = useFrontmatter<{ custom: string }>()
|
|
22
|
+
* console.log(fm.value.custom)
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function useFrontmatter<T extends Record<string, any> = PostFrontMatter>() {
|
|
9
26
|
// inject not in app root
|
|
10
27
|
const route = useRoute()
|
|
11
|
-
const frontmatter = computed
|
|
12
|
-
return route.meta.frontmatter || {}
|
|
28
|
+
const frontmatter = computed(() => {
|
|
29
|
+
return route.meta.frontmatter as Partial<PostFrontMatter & T> || {}
|
|
13
30
|
})
|
|
14
31
|
return frontmatter
|
|
15
32
|
}
|
|
@@ -32,7 +32,6 @@ export function useValaxyDark(options: {
|
|
|
32
32
|
import('valaxy/client/styles/common/view-transition.css')
|
|
33
33
|
|
|
34
34
|
function toggleDarkWithTransition(event: MouseEvent, options: { duration?: number, easing?: EffectTiming['easing'] } = {}) {
|
|
35
|
-
// @ts-expect-error startViewTransition is not defined
|
|
36
35
|
if (!document.startViewTransition) {
|
|
37
36
|
toggleDark()
|
|
38
37
|
return
|
|
@@ -45,7 +44,6 @@ export function useValaxyDark(options: {
|
|
|
45
44
|
Math.max(y, innerHeight - y),
|
|
46
45
|
)
|
|
47
46
|
|
|
48
|
-
// @ts-expect-error startViewTransition is not defined
|
|
49
47
|
const transition = document.startViewTransition(() => {
|
|
50
48
|
toggleDark()
|
|
51
49
|
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useSiteConfig } from 'valaxy'
|
|
2
|
+
import { onBeforeMount, ref } from 'vue'
|
|
3
|
+
|
|
4
|
+
export const timezone = ref<string>()
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* use timezone
|
|
8
|
+
* register global timezone for formatDate
|
|
9
|
+
*/
|
|
10
|
+
export function useTimezone() {
|
|
11
|
+
const siteConfig = useSiteConfig()
|
|
12
|
+
|
|
13
|
+
onBeforeMount(() => {
|
|
14
|
+
timezone.value = siteConfig.value.timezone
|
|
15
|
+
})
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface CollectionConfig {
|
|
2
|
+
/**
|
|
3
|
+
* auto-generated by your collection path
|
|
4
|
+
* @example /collections/love-letters/1 => id: 'love-letters'
|
|
5
|
+
*/
|
|
6
|
+
id?: string
|
|
7
|
+
/**
|
|
8
|
+
* @en
|
|
9
|
+
* The name of the collection.
|
|
10
|
+
*
|
|
11
|
+
* @zh
|
|
12
|
+
* 合集名称
|
|
13
|
+
*/
|
|
14
|
+
name?: string
|
|
15
|
+
cover?: string
|
|
16
|
+
description?: string
|
|
17
|
+
categories?: string[]
|
|
18
|
+
tags?: string[]
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @experimental
|
|
23
|
+
* @description Define the collection configuration.
|
|
24
|
+
*/
|
|
25
|
+
export function defineCollection(config: CollectionConfig) {
|
|
26
|
+
return config
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './collection'
|
package/client/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import FloatingVue from 'floating-vue'
|
|
2
|
+
import type { ViteSSGContext } from 'vite-ssg'
|
|
3
|
+
|
|
4
|
+
import 'floating-vue/dist/style.css'
|
|
5
|
+
import type { DefaultTheme, ValaxyConfig } from 'valaxy/types'
|
|
6
|
+
import type { ComputedRef } from 'vue'
|
|
7
|
+
|
|
8
|
+
export async function install({ app }: ViteSSGContext, config: ComputedRef<ValaxyConfig<DefaultTheme.Config>>) {
|
|
9
|
+
app.use(FloatingVue, config.value.siteConfig.floatingVue)
|
|
10
|
+
}
|
package/client/modules/valaxy.ts
CHANGED
|
@@ -42,17 +42,18 @@ function shouldHotReload(payload: PageDataPayload): boolean {
|
|
|
42
42
|
return ensureSuffix('/', encodeURI(payloadPath)) === ensureSuffix('/', encodeURI(locationPath))
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
// init i18n, by valaxy config
|
|
46
|
+
export const i18n = createI18n({
|
|
47
|
+
legacy: false,
|
|
48
|
+
locale: '',
|
|
49
|
+
messages: valaxyMessages,
|
|
50
|
+
})
|
|
51
|
+
|
|
45
52
|
export async function install({ app, router }: ViteSSGContext, config: ComputedRef<ValaxyConfig<DefaultTheme.Config>>) {
|
|
46
53
|
const locale = useStorage('valaxy-locale', config?.value.siteConfig.lang || 'en')
|
|
54
|
+
i18n.global.locale.value = locale.value
|
|
47
55
|
|
|
48
|
-
// init i18n, by valaxy config
|
|
49
|
-
const i18n = createI18n({
|
|
50
|
-
legacy: false,
|
|
51
|
-
locale: locale.value,
|
|
52
|
-
messages: valaxyMessages,
|
|
53
|
-
})
|
|
54
56
|
app.use(i18n)
|
|
55
|
-
|
|
56
57
|
router.isReady().then(() => {
|
|
57
58
|
handleHMR(router)
|
|
58
59
|
})
|
package/client/setup/main.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { install as installValaxy } from '../modules/valaxy'
|
|
|
13
13
|
import { install as installPinia } from '../modules/pinia'
|
|
14
14
|
import { install as installNprogress } from '../modules/nprogress'
|
|
15
15
|
import { install as installSchema } from '../modules/schemaOrg'
|
|
16
|
+
import { install as installFloatingVue } from '../modules/floating-vue'
|
|
16
17
|
|
|
17
18
|
export default function setupMain(ctx: ViteSSGContext, config: ComputedRef<ValaxyConfig<DefaultTheme.Config>>) {
|
|
18
19
|
// @ts-expect-error inject in runtime
|
|
@@ -23,6 +24,7 @@ export default function setupMain(ctx: ViteSSGContext, config: ComputedRef<Valax
|
|
|
23
24
|
installSchema(ctx)
|
|
24
25
|
installPinia(ctx)
|
|
25
26
|
installNprogress(ctx)
|
|
27
|
+
installFloatingVue(ctx, config)
|
|
26
28
|
|
|
27
29
|
if (import.meta.env.DEV && ctx.isClient) {
|
|
28
30
|
import('../modules/devtools').then(({ install: installDevtools }) => {
|
|
@@ -54,7 +54,8 @@ $light: map.merge(
|
|
|
54
54
|
"c-text-lighter": #666,
|
|
55
55
|
"c-text-dark": #111,
|
|
56
56
|
|
|
57
|
-
"c-primary-rgb": #{color.red($c-primary), color.green($c-primary), color.blue($c-primary)},
|
|
57
|
+
// "c-primary-rgb": #{color.red($c-primary), color.green($c-primary), color.blue($c-primary)},
|
|
58
|
+
"c-primary-rgb": #{color.channel($c-primary, 'red'), color.channel($c-primary, 'green'), color.channel($c-primary, 'blue')},
|
|
58
59
|
|
|
59
60
|
"c-link": get-css-var("c-primary-dark"),
|
|
60
61
|
),
|
package/client/utils/time.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ToDateOptionsWithTZ } from 'date-fns-tz'
|
|
2
2
|
import { format as formatWithTZ, toZonedTime } from 'date-fns-tz'
|
|
3
3
|
import { format, toDate } from 'date-fns'
|
|
4
|
-
import { useSiteConfig } from 'valaxy'
|
|
5
|
-
import { useI18n } from 'vue-i18n'
|
|
6
4
|
import { DateTime } from 'luxon'
|
|
7
5
|
import type { Post } from '../../types'
|
|
6
|
+
import { i18n } from '../modules/valaxy'
|
|
7
|
+
import { timezone as globalTimezone } from '../composables/global'
|
|
8
8
|
|
|
9
9
|
const referenceDate = new Date(1986, 3 /* Apr */, 4, 10, 32, 0, 900)
|
|
10
10
|
|
|
@@ -16,10 +16,9 @@ const referenceDate = new Date(1986, 3 /* Apr */, 4, 10, 32, 0, 900)
|
|
|
16
16
|
* @param options the object with options. See [Options]{@link https://date-fns.org/docs/Options}
|
|
17
17
|
*/
|
|
18
18
|
export function formatDate(date: string | number | Date, formatStr = 'yyyy-MM-dd', timezone?: string, options?: ToDateOptionsWithTZ): string {
|
|
19
|
-
const
|
|
20
|
-
const siteConfig = useSiteConfig()
|
|
19
|
+
const locale = i18n.global.locale.value
|
|
21
20
|
|
|
22
|
-
const mergedOptions: ToDateOptionsWithTZ = Object.assign({ locale: { code: locale
|
|
21
|
+
const mergedOptions: ToDateOptionsWithTZ = Object.assign({ locale: { code: locale } }, options)
|
|
23
22
|
const clientTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
24
23
|
|
|
25
24
|
try {
|
|
@@ -27,7 +26,7 @@ export function formatDate(date: string | number | Date, formatStr = 'yyyy-MM-dd
|
|
|
27
26
|
* Format the timezone-less date to ISO. If none is specified, use the client's timezone.
|
|
28
27
|
* If the input date is already in ISO format, the timezone won't be applied.
|
|
29
28
|
*/
|
|
30
|
-
date = handleTimeWithZone(date, timezone ||
|
|
29
|
+
date = handleTimeWithZone(date, timezone || globalTimezone.value || clientTimezone).toString()
|
|
31
30
|
// Convert to the client's timezone unless the user specifies otherwise
|
|
32
31
|
const zonedDate = toZonedTime(date, options?.timeZone || clientTimezone, mergedOptions)
|
|
33
32
|
// The format function will never change the underlying date
|