Added global search page files to repo.
This commit is contained in:
11
pages/search/+Page.vue
Normal file
11
pages/search/+Page.vue
Normal file
@@ -0,0 +1,11 @@
|
||||
<template>
|
||||
<div>
|
||||
<Scenes
|
||||
default-scope="results"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import Scenes from '#/components/scenes/scenes.vue';
|
||||
</script>
|
||||
36
pages/search/+onBeforeRender.js
Normal file
36
pages/search/+onBeforeRender.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import { fetchScenes } from '#/src/scenes.js';
|
||||
import { curateScenesQuery } from '#/src/web/scenes.js';
|
||||
|
||||
export async function onBeforeRender(pageContext) {
|
||||
const searchScenes = await fetchScenes(await curateScenesQuery({
|
||||
...pageContext.urlQuery,
|
||||
query: pageContext.urlParsed.search.q,
|
||||
scope: pageContext.urlParsed.search.scope || 'results',
|
||||
}), {
|
||||
page: Number(pageContext.routeParams.page) || 1,
|
||||
limit: Number(pageContext.urlParsed.search.limit) || 30,
|
||||
});
|
||||
|
||||
const {
|
||||
scenes,
|
||||
aggActors,
|
||||
aggTags,
|
||||
aggChannels,
|
||||
total,
|
||||
limit,
|
||||
} = searchScenes;
|
||||
|
||||
return {
|
||||
pageContext: {
|
||||
title: `Search '${pageContext.urlParsed.search.q}'`,
|
||||
pageProps: {
|
||||
scenes,
|
||||
aggActors,
|
||||
aggTags,
|
||||
aggChannels,
|
||||
limit,
|
||||
total,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
20
pages/search/+route.js
Normal file
20
pages/search/+route.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import { match } from 'path-to-regexp';
|
||||
// import { resolveRoute } from 'vike/routing'; // eslint-disable-line import/extensions
|
||||
|
||||
const path = '/search/:page?';
|
||||
const urlMatch = match(path, { decode: decodeURIComponent });
|
||||
|
||||
export default (pageContext) => {
|
||||
const matched = urlMatch(pageContext.urlPathname);
|
||||
|
||||
if (matched) {
|
||||
return {
|
||||
routeParams: {
|
||||
page: matched.params.page || '1',
|
||||
path,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
Reference in New Issue
Block a user