valaxy 0.18.9 → 0.18.10
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 +1 -1
- package/client/utils/router.ts +48 -0
- package/dist/{chunk-F2X3NOEJ.mjs → chunk-57MNPFIN.mjs} +3 -3
- package/dist/{chunk-4B74DZJ5.cjs → chunk-KIFZXMGL.cjs} +18 -18
- package/dist/{config-Kdq8Mya1.d.cts → config-D40lUB2J.d.cts} +62 -26
- package/dist/{config-Kdq8Mya1.d.ts → config-D40lUB2J.d.ts} +62 -26
- 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 +6 -3
- package/dist/types/index.d.ts +6 -3
- package/dist/types/index.mjs +1 -1
- package/package.json +12 -12
- package/types/config.ts +1 -1
- package/types/frontmatter/index.ts +2 -0
- package/types/frontmatter/page.ts +191 -0
- package/types/frontmatter/post.ts +103 -0
- package/types/index.ts +1 -0
- package/types/posts.ts +1 -253
- /package/dist/{chunk-YO6XYYV3.cjs → chunk-EKEE6AAY.cjs} +0 -0
- /package/dist/{chunk-42NDXDT3.mjs → chunk-OE2XGI4S.mjs} +0 -0
|
@@ -44,7 +44,7 @@ useVanillaLazyLoad()
|
|
|
44
44
|
</script>
|
|
45
45
|
|
|
46
46
|
<template>
|
|
47
|
-
<article v-if="$slots.default" :class="frontmatter.
|
|
47
|
+
<article v-if="$slots.default" :class="frontmatter.markdownClass || 'markdown-body'">
|
|
48
48
|
<slot ref="contentRef" @vue:updated="runContentUpdated" />
|
|
49
49
|
|
|
50
50
|
<div v-if="frontmatter.url" text="center">
|
package/client/utils/router.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Router } from 'vue-router'
|
|
2
|
+
|
|
1
3
|
export interface ScrollToOptions {
|
|
2
4
|
/**
|
|
3
5
|
* 平滑滚动
|
|
@@ -43,3 +45,49 @@ export function scrollTo(el: HTMLElement, hash: string, options: Partial<ScrollT
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @description Intercept click events and handle offset positions for jump links on the same page
|
|
51
|
+
* @description:zh-CN 拦截点击事件,处理同一页面下跳转链接的偏移位置
|
|
52
|
+
* @param router Vue Router
|
|
53
|
+
*/
|
|
54
|
+
export function onClickHref(router: Router) {
|
|
55
|
+
// to extract
|
|
56
|
+
// click title scroll
|
|
57
|
+
window.addEventListener(
|
|
58
|
+
'click',
|
|
59
|
+
async (e) => {
|
|
60
|
+
const link = (e.target as Element).closest('a')
|
|
61
|
+
if (link) {
|
|
62
|
+
const { protocol, hostname, pathname, hash, target } = link
|
|
63
|
+
const currentUrl = window.location
|
|
64
|
+
const extMatch = pathname.match(/\.\w+$/)
|
|
65
|
+
// only intercept inbound links
|
|
66
|
+
if (
|
|
67
|
+
!e.ctrlKey
|
|
68
|
+
&& !e.shiftKey
|
|
69
|
+
&& !e.altKey
|
|
70
|
+
&& !e.metaKey
|
|
71
|
+
&& target !== '_blank'
|
|
72
|
+
&& protocol === currentUrl.protocol
|
|
73
|
+
&& hostname === currentUrl.hostname
|
|
74
|
+
&& !(extMatch && extMatch[0] !== '.html')
|
|
75
|
+
) {
|
|
76
|
+
if (pathname === currentUrl.pathname) {
|
|
77
|
+
e.preventDefault()
|
|
78
|
+
// scroll between hash anchors in the same page
|
|
79
|
+
if (hash && hash !== currentUrl.hash) {
|
|
80
|
+
await router.push({ hash: decodeURIComponent(hash) })
|
|
81
|
+
|
|
82
|
+
// use smooth scroll when clicking on header anchor links
|
|
83
|
+
scrollTo(link, hash, {
|
|
84
|
+
smooth: link.classList.contains('header-anchor'),
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{ capture: true },
|
|
92
|
+
)
|
|
93
|
+
}
|