diff --git a/src/client/app/router.ts b/src/client/app/router.ts index 3c6fb4f7f42f..9e06d8a95181 100644 --- a/src/client/app/router.ts +++ b/src/client/app/router.ts @@ -1,7 +1,7 @@ import type { Component, InjectionKey } from 'vue' import { inject, markRaw, nextTick, reactive, readonly } from 'vue' import type { Awaitable, PageData, PageDataPayload } from '../shared' -import { notFoundPageData, treatAsHtml } from '../shared' +import { notFoundPageData, searchPageData, treatAsHtml } from '../shared' import { siteDataRef } from './data' import { getScrollOffset, inBrowser, withBase } from './utils' @@ -58,7 +58,8 @@ interface PageModule { export function createRouter( loadPageModule: (path: string) => Awaitable, - fallbackComponent?: Component + fallbackComponent?: Component, + searchComponent?: Component ): Router { const route = reactive(getDefaultRoute()) @@ -85,6 +86,14 @@ export function createRouter( if ((await router.onBeforePageLoad?.(href)) === false) return const targetLoc = new URL(href, fakeHost) const pendingPath = (latestPendingPath = targetLoc.pathname) + + if (pendingPath === '/search') { + route.path = inBrowser ? pendingPath : withBase(pendingPath) + route.component = searchComponent ? markRaw(searchComponent) : null + route.data = searchPageData + return + } + try { let page = await loadPageModule(pendingPath) if (!page) { diff --git a/src/client/theme-default/Search.vue b/src/client/theme-default/Search.vue new file mode 100644 index 000000000000..56761d003c9b --- /dev/null +++ b/src/client/theme-default/Search.vue @@ -0,0 +1,69 @@ + + + + + diff --git a/src/client/theme-default/components/VPContent.vue b/src/client/theme-default/components/VPContent.vue index 3b2dbdf6e0ff..6e2e522b9f05 100644 --- a/src/client/theme-default/components/VPContent.vue +++ b/src/client/theme-default/components/VPContent.vue @@ -1,5 +1,6 @@