valaxy 0.19.7 → 0.19.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/ValaxyLogo.vue +1 -1
- package/client/pages/[...path].vue +0 -2
- package/client/utils/time.ts +56 -12
- package/client/utils/wrap.ts +2 -0
- package/dist/{chunk-2ELKTCRW.cjs → chunk-ELKBAUEC.cjs} +34 -34
- package/dist/{chunk-WJ7ANASU.mjs → chunk-MVWDJMOK.mjs} +35 -35
- package/dist/{config-BuLv3zWm.d.cts → config-_Vh4V6Lh.d.cts} +9 -0
- package/dist/{config-BuLv3zWm.d.ts → config-_Vh4V6Lh.d.ts} +9 -0
- 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 +1 -1
- package/dist/node/index.d.ts +1 -1
- 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 +25 -23
- package/types/config.ts +9 -0
- /package/dist/{chunk-MXUQVQLG.cjs → chunk-635QRI6N.cjs} +0 -0
- /package/dist/{chunk-JA4TFOJM.mjs → chunk-FDUDFMUS.mjs} +0 -0
|
@@ -5,7 +5,7 @@ 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 w="50" aspect="420/386" m="auto" :src="valaxyLogoPng" alt="Valaxy Logo" z="1">
|
|
8
|
+
<img class="fly-animation" w="50" aspect="420/386" m="auto" :src="valaxyLogoPng" alt="Valaxy Logo" z="1">
|
|
9
9
|
</div>
|
|
10
10
|
</template>
|
|
11
11
|
|
package/client/utils/time.ts
CHANGED
|
@@ -1,21 +1,65 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ToDateOptionsWithTZ } from 'date-fns-tz'
|
|
2
|
+
import { format as formatWithTZ, toZonedTime } from 'date-fns-tz'
|
|
3
|
+
import { format, toDate } from 'date-fns'
|
|
4
|
+
import { useSiteConfig } from 'valaxy'
|
|
5
|
+
import { useI18n } from 'vue-i18n'
|
|
6
|
+
import { DateTime } from 'luxon'
|
|
2
7
|
import type { Post } from '../../types'
|
|
3
8
|
|
|
9
|
+
const referenceDate = new Date(1986, 3 /* Apr */, 4, 10, 32, 0, 900)
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @param date
|
|
7
|
-
* @param
|
|
12
|
+
* format the date
|
|
13
|
+
* @param date the original date
|
|
14
|
+
* @param formatStr the string of tokens
|
|
15
|
+
* @param timezone the time zone of this local time, can be an offset or IANA time zone
|
|
16
|
+
* @param options the object with options. See [Options]{@link https://date-fns.org/docs/Options}
|
|
8
17
|
*/
|
|
9
|
-
export function formatDate(date: string | number | Date,
|
|
10
|
-
|
|
18
|
+
export function formatDate(date: string | number | Date, formatStr = 'yyyy-MM-dd', timezone?: string, options?: ToDateOptionsWithTZ): string {
|
|
19
|
+
const { locale } = useI18n()
|
|
20
|
+
const siteConfig = useSiteConfig()
|
|
21
|
+
|
|
22
|
+
const mergedOptions: ToDateOptionsWithTZ = Object.assign({ locale: { code: locale.value } }, options)
|
|
23
|
+
const clientTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
/**
|
|
27
|
+
* Format the timezone-less date to ISO. If none is specified, use the client's timezone.
|
|
28
|
+
* If the input date is already in ISO format, the timezone won't be applied.
|
|
29
|
+
*/
|
|
30
|
+
date = handleTimeWithZone(date, timezone || siteConfig.value.timezone || clientTimezone).toString()
|
|
31
|
+
// Convert to the client's timezone unless the user specifies otherwise
|
|
32
|
+
const zonedDate = toZonedTime(date, options?.timeZone || clientTimezone, mergedOptions)
|
|
33
|
+
// The format function will never change the underlying date
|
|
34
|
+
return formatWithTZ(zonedDate, formatStr, { timeZone: options?.timeZone })
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
console.error(
|
|
38
|
+
'The date format provided is non-standard. The recommended format is \'yyyy-MM-dd HH:mm:ss\'',
|
|
39
|
+
'\nError formatting date:',
|
|
40
|
+
date.toString(),
|
|
41
|
+
error,
|
|
42
|
+
)
|
|
43
|
+
return format(referenceDate, formatStr)
|
|
44
|
+
}
|
|
11
45
|
}
|
|
12
46
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
47
|
+
function handleTimeWithZone(date: string | number | Date, timezone: string) {
|
|
48
|
+
if (typeof date !== 'string')
|
|
49
|
+
date = toDate(date).toISOString()
|
|
50
|
+
|
|
51
|
+
let dateTime = DateTime.fromISO(date, { setZone: true })
|
|
52
|
+
|
|
53
|
+
const toDateTime = (date: string, zone: string) => {
|
|
54
|
+
// Attempt to format the date using a function that handles non-ISO 8601 formats
|
|
55
|
+
const isoDate = format(date, 'yyyy-MM-dd\'T\'HH:mm:ss')
|
|
56
|
+
return DateTime.fromISO(isoDate, { zone })
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!dateTime.isValid || !dateTime.zoneName)
|
|
60
|
+
dateTime = toDateTime(date, timezone)
|
|
61
|
+
|
|
62
|
+
return dateTime
|
|
19
63
|
}
|
|
20
64
|
|
|
21
65
|
/**
|
package/client/utils/wrap.ts
CHANGED
|
@@ -14,6 +14,8 @@ export function wrap(el: HTMLElement, className: string) {
|
|
|
14
14
|
*/
|
|
15
15
|
export function wrapTable(container: HTMLElement | Document = document) {
|
|
16
16
|
container.querySelectorAll('table').forEach((el) => {
|
|
17
|
+
if (el.parentElement?.classList.contains('table-container'))
|
|
18
|
+
return
|
|
17
19
|
const container = document.createElement('div')
|
|
18
20
|
container.className = 'table-container'
|
|
19
21
|
wrap(el, 'table-container')
|