diff --git a/pages/search/+Page.vue b/pages/search/+Page.vue new file mode 100644 index 0000000..8cbc47f --- /dev/null +++ b/pages/search/+Page.vue @@ -0,0 +1,11 @@ + + + diff --git a/pages/search/+onBeforeRender.js b/pages/search/+onBeforeRender.js new file mode 100644 index 0000000..3ea908d --- /dev/null +++ b/pages/search/+onBeforeRender.js @@ -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, + }, + }, + }; +} diff --git a/pages/search/+route.js b/pages/search/+route.js new file mode 100644 index 0000000..cd4f77f --- /dev/null +++ b/pages/search/+route.js @@ -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; +}; diff --git a/static b/static index 4b9b3ca..62c8a04 160000 --- a/static +++ b/static @@ -1 +1 @@ -Subproject commit 4b9b3ca0cb868539b9a1001c40587aef19ec59bb +Subproject commit 62c8a043692d973e6aadb45f3ca3dfc78466f3b6