valaxy 0.16.3 → 0.17.0-beta.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.
- package/client/composables/features/vanilla-lazyload.ts +7 -0
- package/client/composables/post.ts +2 -2
- package/client/{template.html → index.html} +1 -1
- package/client/layouts/README.md +1 -1
- package/client/layouts/default.vue +1 -1
- package/client/layouts/post.vue +1 -1
- package/client/main.ts +15 -8
- package/client/modules/devtools.ts +60 -0
- package/client/modules/valaxy.ts +1 -1
- package/client/setup/main.ts +6 -0
- package/client/styles/palette.scss +0 -1
- package/dist/chunk-EG3RHL6A.mjs +150 -0
- package/dist/{chunk-R6EC3UMQ.cjs → chunk-GXMNHGBP.cjs} +1 -1
- package/dist/chunk-I374XGD2.cjs +149 -0
- package/dist/{chunk-YTQABADX.mjs → chunk-WSC7UAH5.mjs} +1 -1
- package/dist/{config-tjZfKSoC.d.cts → config-OaNeBI1c.d.cts} +10 -1
- package/dist/{config-tjZfKSoC.d.ts → config-OaNeBI1c.d.ts} +10 -1
- 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 +14 -13
- package/dist/node/index.d.ts +14 -13
- 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 +16 -14
- package/types/config.ts +11 -0
- package/client/layouts/layout.vue +0 -39
- package/dist/chunk-KMYBWFOB.mjs +0 -135
- package/dist/chunk-O6VYMTHE.cjs +0 -134
- /package/client/pages/{[...all].vue → [...path].vue} +0 -0
|
@@ -3,6 +3,13 @@ import LazyLoad from 'vanilla-lazyload'
|
|
|
3
3
|
import { onMounted } from 'vue'
|
|
4
4
|
|
|
5
5
|
function createLazyLoadInstance(options = {}) {
|
|
6
|
+
// not removeSrc in markdown-it-image-figures for vite handle relative path in src
|
|
7
|
+
document.querySelectorAll('.lazy').forEach((el) => {
|
|
8
|
+
const imgSrc = el.getAttribute('src')
|
|
9
|
+
el.removeAttribute('src')
|
|
10
|
+
el.setAttribute('data-src', imgSrc ?? '')
|
|
11
|
+
})
|
|
12
|
+
|
|
6
13
|
return new LazyLoad({
|
|
7
14
|
elements_selector: '.lazy',
|
|
8
15
|
...options,
|
|
@@ -19,7 +19,7 @@ export function usePostTitle(post: ComputedRef<Post>) {
|
|
|
19
19
|
*/
|
|
20
20
|
export function usePageList() {
|
|
21
21
|
return computed<Post[]>(() => {
|
|
22
|
-
const excludePages = ['/:..all', '/:all(.*)*', '/']
|
|
22
|
+
const excludePages = ['/:..all', '/:all(.*)*', '/', '/:path(.*)']
|
|
23
23
|
const router = useRouter()
|
|
24
24
|
const routes = router.getRoutes()
|
|
25
25
|
.filter(i => i.name)
|
|
@@ -27,7 +27,7 @@ export function usePageList() {
|
|
|
27
27
|
.filter(i => i.meta!.frontmatter)
|
|
28
28
|
.filter(i => i.path && !excludePages.includes(i.path))
|
|
29
29
|
.map((i) => {
|
|
30
|
-
return Object.assign({ path: i.path, excerpt: i.meta!.excerpt }, i.meta!.frontmatter) as Post
|
|
30
|
+
return Object.assign({ path: i.path, excerpt: i.meta!.excerpt }, i.meta!.frontmatter || {}) as Post
|
|
31
31
|
})
|
|
32
32
|
return routes
|
|
33
33
|
})
|
package/client/layouts/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Vue components in this dir are used as layouts.
|
|
|
4
4
|
|
|
5
5
|
By default, `default.vue` will be used unless an alternative is specified in the route meta.
|
|
6
6
|
|
|
7
|
-
With [
|
|
7
|
+
With [unplugin-vue-router](https://github.com/posva/unplugin-vue-router) and [`vite-plugin-vue-layouts`](https://github.com/JohnCampionJr/vite-plugin-vue-layouts), you can specify the layout in the page's SFCs like this:
|
|
8
8
|
|
|
9
9
|
```html
|
|
10
10
|
<route lang="yaml">
|
package/client/layouts/post.vue
CHANGED
package/client/main.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ViteSSGContext } from 'vite-ssg'
|
|
2
2
|
import { ViteSSG } from 'vite-ssg'
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { routes } from 'vue-router/auto/routes'
|
|
4
5
|
import { setupLayouts } from 'virtual:generated-layouts'
|
|
5
6
|
|
|
6
7
|
import { initValaxyConfig, valaxyConfigSymbol } from 'valaxy'
|
|
@@ -20,12 +21,6 @@ import 'uno.css'
|
|
|
20
21
|
|
|
21
22
|
import setupMain from './setup/main'
|
|
22
23
|
|
|
23
|
-
const routes = setupLayouts(import.meta.env.DEV
|
|
24
|
-
? generatedRoutes
|
|
25
|
-
: generatedRoutes.filter(i =>
|
|
26
|
-
i.meta && i.meta.frontmatter && !i.meta.frontmatter.draft,
|
|
27
|
-
))
|
|
28
|
-
|
|
29
24
|
/**
|
|
30
25
|
* register global components
|
|
31
26
|
* @param ctx
|
|
@@ -34,13 +29,25 @@ export function registerComponents(ctx: ViteSSGContext) {
|
|
|
34
29
|
ctx.app.component('AppLink', AppLink)
|
|
35
30
|
}
|
|
36
31
|
|
|
32
|
+
// fix chinese path
|
|
33
|
+
routes.forEach((i) => {
|
|
34
|
+
i.children?.forEach((j) => {
|
|
35
|
+
j.path = encodeURI(j.path)
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
37
39
|
// not filter hide for ssg
|
|
40
|
+
const routesWithLayout = setupLayouts(import.meta.env.DEV
|
|
41
|
+
? routes
|
|
42
|
+
: routes.filter(i =>
|
|
43
|
+
i.meta && i.meta.frontmatter && !i.meta.frontmatter.draft,
|
|
44
|
+
))
|
|
38
45
|
|
|
39
46
|
// https://github.com/antfu/vite-ssg
|
|
40
47
|
export const createApp = ViteSSG(
|
|
41
48
|
App,
|
|
42
49
|
{
|
|
43
|
-
routes,
|
|
50
|
+
routes: routesWithLayout,
|
|
44
51
|
base: import.meta.env.BASE_URL,
|
|
45
52
|
scrollBehavior(to, from) {
|
|
46
53
|
if (to.path !== from.path)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { UserModule } from '../types'
|
|
2
|
+
|
|
3
|
+
import valaxyLogo from '../assets/images/valaxy-logo.png'
|
|
4
|
+
import pkg from '../../package.json'
|
|
5
|
+
|
|
6
|
+
// import {addCustomCommand, addCustomTab } from '@vue/devtools-api'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* add when enable vue devtools
|
|
10
|
+
* https://devtools-next.vuejs.org/plugins/api
|
|
11
|
+
*/
|
|
12
|
+
export async function addValaxyTabAndCommand() {
|
|
13
|
+
const { addCustomTab, addCustomCommand } = await import('@vue/devtools-api')
|
|
14
|
+
addCustomTab({
|
|
15
|
+
// unique identifier
|
|
16
|
+
name: 'valaxy',
|
|
17
|
+
// title to display in the tab
|
|
18
|
+
title: 'Valaxy',
|
|
19
|
+
// any icon from Iconify, or a URL to an image
|
|
20
|
+
icon: valaxyLogo,
|
|
21
|
+
// iframe view
|
|
22
|
+
view: {
|
|
23
|
+
type: 'iframe',
|
|
24
|
+
src: 'https://valaxy.site',
|
|
25
|
+
},
|
|
26
|
+
// category: 'pinned',
|
|
27
|
+
category: 'app',
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
addCustomCommand({
|
|
31
|
+
id: 'valaxy',
|
|
32
|
+
title: 'Valaxy',
|
|
33
|
+
icon: valaxyLogo,
|
|
34
|
+
children: [
|
|
35
|
+
{
|
|
36
|
+
id: 'valaxy:github',
|
|
37
|
+
title: 'Github',
|
|
38
|
+
icon: 'i-ri-github-fill',
|
|
39
|
+
action: {
|
|
40
|
+
type: 'url',
|
|
41
|
+
src: pkg.repository.url,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'valaxy:website',
|
|
46
|
+
title: 'Website',
|
|
47
|
+
icon: valaxyLogo,
|
|
48
|
+
action: {
|
|
49
|
+
type: 'url',
|
|
50
|
+
src: 'https://valaxy.site/',
|
|
51
|
+
},
|
|
52
|
+
order: 2,
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const install: UserModule = async () => {
|
|
59
|
+
await addValaxyTabAndCommand()
|
|
60
|
+
}
|
package/client/modules/valaxy.ts
CHANGED
|
@@ -43,7 +43,7 @@ function shouldHotReload(payload: PageDataPayload): boolean {
|
|
|
43
43
|
return ensureSuffix('/', payloadPath) === ensureSuffix('/', locationPath)
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function install({ app, router }: ViteSSGContext, config: ComputedRef<ValaxyConfig<DefaultTheme.Config>>) {
|
|
46
|
+
export async function install({ app, router }: ViteSSGContext, config: ComputedRef<ValaxyConfig<DefaultTheme.Config>>) {
|
|
47
47
|
const locale = useStorage('valaxy-locale', config?.value.siteConfig.lang || 'en')
|
|
48
48
|
|
|
49
49
|
// init i18n, by valaxy config
|
package/client/setup/main.ts
CHANGED
|
@@ -26,6 +26,12 @@ export default function setupMain(ctx: ViteSSGContext, config: ComputedRef<Valax
|
|
|
26
26
|
|
|
27
27
|
installValaxy(ctx, config)
|
|
28
28
|
|
|
29
|
+
if (import.meta.env.DEV && ctx.isClient) {
|
|
30
|
+
import('../modules/devtools').then(({ install: installDevtools }) => {
|
|
31
|
+
installDevtools(ctx)
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
installSchema(ctx)
|
|
30
36
|
|
|
31
37
|
installPinia(ctx)
|