valaxy 0.16.4 → 0.17.0-beta.2

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.
@@ -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
  })
@@ -7,7 +7,7 @@
7
7
  </head>
8
8
  <body>
9
9
  <div id="app"></div>
10
- <script type="module" src="__ENTRY__"></script>
10
+ <script type="module" src="./main.ts"></script>
11
11
  <!-- body -->
12
12
  </body>
13
13
  </html>
@@ -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 [`vite-plugin-pages`](https://github.com/hannoeru/vite-plugin-pages) 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:
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">
@@ -1,3 +1,3 @@
1
1
  <template>
2
- <Layout />
2
+ <RouterView />
3
3
  </template>
@@ -1,3 +1,3 @@
1
1
  <template>
2
- <Layout />
2
+ <RouterView />
3
3
  </template>
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
- import generatedRoutes from 'virtual:generated-pages'
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
+ }
@@ -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
@@ -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)
@@ -63,7 +63,6 @@ $light: map.merge(
63
63
  "c-primary-rgb": #{color.red($c-primary), color.green($c-primary), color.blue($c-primary)},
64
64
 
65
65
  "c-link": get-css-var("c-primary-dark"),
66
- "c-divider": rgba(60, 60, 60, 0.2),
67
66
  ),
68
67
  $light
69
68
  );