Added easily accessible global scenes page with filters.
This commit is contained in:
24
pages/scenes/+Page.vue
Normal file
24
pages/scenes/+Page.vue
Normal file
@@ -0,0 +1,24 @@
|
||||
<template>
|
||||
<div class="updates">
|
||||
<Scenes
|
||||
:show-filters="true"
|
||||
:show-meta="true"
|
||||
:show-scope-tabs="false"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
// import { inject } from 'vue';
|
||||
|
||||
import Scenes from '#/components/scenes/scenes.vue';
|
||||
|
||||
// const pageContext = inject('pageContext');
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.updates {
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
}
|
||||
</style>
|
||||
47
pages/scenes/+onBeforeRender.js
Normal file
47
pages/scenes/+onBeforeRender.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import { fetchScenes } from '#/src/scenes.js';
|
||||
import { curateScenesQuery } from '#/src/web/scenes.js';
|
||||
import { getRandomCampaigns, getCampaignIndex } from '#/src/campaigns.js';
|
||||
|
||||
export async function onBeforeRender(pageContext) {
|
||||
const [
|
||||
sceneResults,
|
||||
campaigns,
|
||||
] = await Promise.all([
|
||||
fetchScenes(await curateScenesQuery({
|
||||
...pageContext.urlQuery,
|
||||
scope: pageContext.routeParams.scope || 'latest',
|
||||
isShowcased: null,
|
||||
tagFilter: pageContext.tagFilter,
|
||||
}), {
|
||||
page: Number(pageContext.routeParams.page) || 1,
|
||||
limit: Number(pageContext.urlParsed.search.limit) || 29,
|
||||
aggregate: true,
|
||||
dedupe: true,
|
||||
}, pageContext.user),
|
||||
getRandomCampaigns([
|
||||
{ minRatio: 0.75, maxRatio: 1.25 },
|
||||
{ minRatio: 1.5 },
|
||||
], { tagFilter: pageContext.tagFilter }),
|
||||
]);
|
||||
|
||||
const {
|
||||
scenes,
|
||||
} = sceneResults;
|
||||
|
||||
const campaignIndex = getCampaignIndex(scenes.length);
|
||||
const [sceneCampaign, paginationCampaign] = campaigns;
|
||||
|
||||
return {
|
||||
pageContext: {
|
||||
title: pageContext.routeParams.scope,
|
||||
pageProps: {
|
||||
...sceneResults,
|
||||
},
|
||||
campaigns: {
|
||||
index: campaignIndex,
|
||||
scenes: scenes.length > 5 && sceneCampaign,
|
||||
pagination: paginationCampaign,
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
21
pages/scenes/+route.js
Normal file
21
pages/scenes/+route.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { match } from 'path-to-regexp';
|
||||
// import { resolveRoute } from 'vike/routing'; // eslint-disable-line import/extensions
|
||||
|
||||
const path = '/scenes/:scope?/:page?';
|
||||
const urlMatch = match(path, { decode: decodeURIComponent });
|
||||
|
||||
export default (pageContext) => {
|
||||
const matched = urlMatch(pageContext.urlPathname);
|
||||
|
||||
if (matched) {
|
||||
return {
|
||||
routeParams: {
|
||||
scope: matched.params.scope || 'latest',
|
||||
page: matched.params.page || '1',
|
||||
path,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
@@ -1,20 +1,20 @@
|
||||
<template>
|
||||
<div class="updates">
|
||||
<Scenes
|
||||
:show-filters="!!query"
|
||||
:show-meta="!!query"
|
||||
:show-scope-tabs="!query"
|
||||
:show-filters="false"
|
||||
:show-meta="false"
|
||||
:show-scope-tabs="true"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { inject } from 'vue';
|
||||
// import { inject } from 'vue';
|
||||
|
||||
import Scenes from '#/components/scenes/scenes.vue';
|
||||
|
||||
const pageContext = inject('pageContext');
|
||||
const query = Object.hasOwn(pageContext.urlParsed.search, 'q');
|
||||
// const pageContext = inject('pageContext');
|
||||
// const query = Object.hasOwn(pageContext.urlParsed.search, 'q');
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user