Skip to content

Commit 5e94d63

Browse files
committed
refactor(client): extract registerGlobalComponents
1 parent 142a7db commit 5e94d63

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

packages/@vuepress/client/src/app.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ import {
1414
START_LOCATION,
1515
} from 'vue-router'
1616
import type { Router } from 'vue-router'
17-
import { ClientOnly, Content, OutboundLink } from './components'
1817
import {
1918
siteData,
2019
pageData,
2120
resolvePageData,
2221
setupUpdateHead,
2322
} from './composables'
2423
import { provideGlobalComputed } from './provideGlobalComputed'
24+
import { registerGlobalComponents } from './registerGlobalComponents'
2525

2626
/**
2727
* - use `createApp` in dev mode
@@ -83,14 +83,9 @@ export const createVueApp: CreateVueAppFunction = async () => {
8383
}
8484
})
8585

86+
// global computed and global components
8687
provideGlobalComputed(app, router)
87-
88-
// register built-in components
89-
/* eslint-disable vue/match-component-file-name */
90-
app.component('ClientOnly', ClientOnly)
91-
app.component('Content', Content)
92-
app.component('OutboundLink', OutboundLink)
93-
/* eslint-enable vue/match-component-file-name */
88+
registerGlobalComponents(app)
9489

9590
// invoke all clientAppEnhances
9691
for (const clientAppEnhance of clientAppEnhances) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { App } from 'vue'
2+
import { ClientOnly, Content, OutboundLink } from './components'
3+
4+
/**
5+
* Register global built-in components
6+
*/
7+
export const registerGlobalComponents = (app: App): void => {
8+
/* eslint-disable vue/match-component-file-name */
9+
app.component('ClientOnly', ClientOnly)
10+
app.component('Content', Content)
11+
app.component('OutboundLink', OutboundLink)
12+
/* eslint-enable vue/match-component-file-name */
13+
}

0 commit comments

Comments
 (0)