forked from antfu/antfu.me
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
60 lines (54 loc) · 1.66 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import dayjs from 'dayjs'
import LocalizedFormat from 'dayjs/plugin/localizedFormat.js'
import FloatingVue from 'floating-vue'
import NProgress from 'nprogress'
import { createPinia } from 'pinia'
import { ViteSSG } from 'vite-ssg'
import { routes } from 'vue-router/auto-routes'
import { setupRouterScroller } from 'vue-router-better-scroller'
import App from './App.vue'
import '@unocss/reset/tailwind.css'
import 'floating-vue/dist/style.css'
import 'markdown-it-github-alerts/styles/github-colors-light.css'
import 'markdown-it-github-alerts/styles/github-colors-dark-class.css'
import 'markdown-it-github-alerts/styles/github-base.css'
import '@shikijs/twoslash/style-rich.css'
import 'shiki-magic-move/style.css'
import './styles/main.css'
import './styles/prose.css'
import './styles/markdown.css'
import 'uno.css'
export const createApp = ViteSSG(
App,
{
routes,
},
({ router, app, isClient }) => {
dayjs.extend(LocalizedFormat)
app.use(FloatingVue)
app.use(createPinia())
if (isClient) {
const html = document.querySelector('html')!
setupRouterScroller(router, {
selectors: {
html(ctx) {
// only do the sliding transition when the scroll position is not 0
// Disable sliding transition on Dev Mode
if (ctx.savedPosition?.top || import.meta.hot)
html.classList.add('no-sliding')
else
html.classList.remove('no-sliding')
return true
},
},
behavior: 'auto',
})
router.beforeEach(() => {
NProgress.start()
})
router.afterEach(() => {
NProgress.done()
})
}
},
)