-
-
Notifications
You must be signed in to change notification settings - Fork 212
/
main.ts
41 lines (36 loc) · 943 Bytes
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import '@unocss/reset/tailwind.css'
import './styles/main.css'
import './styles/prose.css'
import './styles/markdown.css'
import 'uno.css'
import autoRoutes from 'pages-generated'
import NProgress from 'nprogress'
import { ViteSSG } from 'vite-ssg'
import dayjs from 'dayjs'
import LocalizedFormat from 'dayjs/plugin/localizedFormat.js'
import App from './App.vue'
const routes = autoRoutes.map((i) => {
return {
...i,
alias: i.path.endsWith('/')
? `${i.path}index.html`
: `${i.path}.html`,
}
})
const scrollBehavior = (to: any, from: any, savedPosition: any) => {
if (savedPosition)
return savedPosition
else
return { top: 0 }
}
export const createApp = ViteSSG(
App,
{ routes, scrollBehavior },
({ router, isClient }) => {
dayjs.extend(LocalizedFormat)
if (isClient) {
router.beforeEach(() => { NProgress.start() })
router.afterEach(() => { NProgress.done() })
}
},
)