mirror of https://github.com/YunYouJun/valaxy
This commit is contained in:
parent
1b58be3ee3
commit
9fcad8469f
|
@ -114,7 +114,7 @@ pnpm create valaxy
|
|||
import { defineTheme } from 'valaxy'
|
||||
|
||||
export default defineTheme({
|
||||
vueRouter: {
|
||||
router: {
|
||||
extendRoute(route) {
|
||||
// want to get component absolute paths?
|
||||
// const path = route.components.get('default')
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
<script lang="ts" setup>
|
||||
function goDown() {
|
||||
const banner = document.getElementById('yun-banner')
|
||||
if (banner) {
|
||||
window.scrollTo({
|
||||
top: banner.clientHeight,
|
||||
behavior: 'smooth',
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<a class="go-down" aria-label="go-down" href="javascript:window.scrollTo(0, window.banner.clientHeight);">
|
||||
<button class="go-down" aria-label="go-down" @click="goDown">
|
||||
<div i-ri-arrow-down-s-line inline-flex />
|
||||
</a>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
@ -58,7 +58,7 @@ export interface ResolvedValaxyOptions<ThemeConfig = DefaultTheme.Config> {
|
|||
*/
|
||||
addonRoots: string[]
|
||||
/**
|
||||
* Theme name
|
||||
* clientRoot, themeRoot, ...addonRoots, userRoot
|
||||
*/
|
||||
roots: string[]
|
||||
theme: string
|
||||
|
|
|
@ -93,7 +93,8 @@ export async function ViteValaxyPlugins(
|
|||
// https://github.com/JohnCampionJr/vite-plugin-vue-layouts
|
||||
Layouts({
|
||||
layoutsDirs: roots.map(root => `${root}/layouts`),
|
||||
pagesDirs: roots.map(root => `${root}/pages`),
|
||||
|
||||
...valaxyConfig.layouts,
|
||||
}),
|
||||
|
||||
// https://github.com/antfu/unplugin-vue-components
|
||||
|
|
|
@ -9,7 +9,7 @@ import type { Plugin, ResolvedConfig } from 'vite'
|
|||
import { defu } from 'defu'
|
||||
import pascalCase from 'pascalcase'
|
||||
import type { DefaultTheme, PageDataPayload, Pkg, SiteConfig } from 'valaxy/types'
|
||||
import { yellow } from 'kolorist'
|
||||
import { dim, yellow } from 'kolorist'
|
||||
import { defaultSiteConfig, mergeValaxyConfig, resolveSiteConfig, resolveUserThemeConfig } from '../config'
|
||||
import type { ResolvedValaxyOptions, ValaxyServerOptions } from '../options'
|
||||
import { processValaxyOptions, resolveOptions, resolveThemeValaxyConfig } from '../options'
|
||||
|
@ -18,6 +18,7 @@ import { createMarkdownToVueRenderFn } from '../markdown/markdownToVue'
|
|||
import type { ValaxyNodeConfig } from '../types'
|
||||
import { checkMd } from '../markdown/check'
|
||||
import { vLogger } from '../logger'
|
||||
import { countPerformanceTime } from '../utils/performance'
|
||||
|
||||
/**
|
||||
* for /@valaxyjs/styles
|
||||
|
@ -231,6 +232,7 @@ export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions
|
|||
* @param ctx
|
||||
*/
|
||||
async handleHotUpdate(ctx) {
|
||||
const endCount = countPerformanceTime()
|
||||
const { file, server, read } = ctx
|
||||
|
||||
const reloadConfigAndEntries = (config: ValaxyNodeConfig) => {
|
||||
|
@ -302,9 +304,8 @@ export function createValaxyPlugin(options: ResolvedValaxyOptions, serverOptions
|
|||
|
||||
// overwrite src so vue plugin can handle the HMR
|
||||
ctx.read = () => vueSrc
|
||||
vLogger.success(`${yellow('[HMR]')} ${path}`)
|
||||
|
||||
return []
|
||||
vLogger.success(`${yellow('[HMR]')} ${path} ${dim(`updated in ${endCount()}`)}`)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ export function createRouterPlugin(options: ResolvedValaxyOptions) {
|
|||
routesFolder: roots.map(root => `${root}/pages`),
|
||||
dts: `${options.clientRoot}/typed-router.d.ts`,
|
||||
|
||||
...valaxyConfig.vueRouter,
|
||||
...valaxyConfig.router,
|
||||
|
||||
/**
|
||||
* @experimental See https://github.com/posva/unplugin-vue-router/issues/43
|
||||
|
@ -155,7 +155,7 @@ export function createRouterPlugin(options: ResolvedValaxyOptions) {
|
|||
valaxyConfig.extendMd?.(ctx)
|
||||
}
|
||||
|
||||
return valaxyConfig.vueRouter?.extendRoute?.(route)
|
||||
return valaxyConfig.router?.extendRoute?.(route)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import type Vue from '@vitejs/plugin-vue'
|
||||
|
||||
import type Components from 'unplugin-vue-components/vite'
|
||||
import type Layouts from 'vite-plugin-vue-layouts'
|
||||
import type Router from 'unplugin-vue-router/vite'
|
||||
|
||||
import type { VitePluginConfig as UnoCSSConfig } from 'unocss/vite'
|
||||
import type VueRouter from 'unplugin-vue-router/vite'
|
||||
import type { EditableTreeNode } from 'unplugin-vue-router'
|
||||
import type { UserConfig as ViteUserConfig } from 'vite'
|
||||
import type { presetAttributify, presetIcons, presetTypography, presetUno } from 'unocss'
|
||||
|
@ -66,7 +69,11 @@ export interface ValaxyExtendConfig {
|
|||
|
||||
vite?: ViteUserConfig
|
||||
vue?: Parameters<typeof Vue>[0]
|
||||
// unplugin
|
||||
components?: Parameters<typeof Components>[0]
|
||||
layouts?: Parameters<typeof Layouts>[0]
|
||||
router?: Parameters<typeof Router>[0]
|
||||
|
||||
unocss?: UnoCSSConfig
|
||||
/**
|
||||
* unocss presets
|
||||
|
@ -77,7 +84,6 @@ export interface ValaxyExtendConfig {
|
|||
icons?: Parameters<typeof presetIcons>[0]
|
||||
typography?: Parameters<typeof presetTypography>[0]
|
||||
}
|
||||
vueRouter?: Parameters<typeof VueRouter>[0]
|
||||
/**
|
||||
* @experimental
|
||||
* Enable Vue Devtools & Valaxy Devtools
|
||||
|
|
Loading…
Reference in New Issue