Redirecting aliased actors and tags.
This commit is contained in:
@@ -47,6 +47,10 @@ export async function onBeforeRender(pageContext) {
|
||||
throw render(404, `Cannot find actor '${pageContext.routeParams.actorId}'.`);
|
||||
}
|
||||
|
||||
if (actor.alias && !Object.hasOwn(pageContext.urlParsed.search, 'inspect')) {
|
||||
throw redirect(`/actor/${actor.alias.id}/${actor.alias.slug}`);
|
||||
}
|
||||
|
||||
const [actorReleases, campaigns, countries] = await Promise.all([
|
||||
fetchReleases(pageContext),
|
||||
getRandomCampaigns([
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
>
|
||||
<td class="actor-id ellipsis">
|
||||
<a
|
||||
:href="`/actor/${actor.id}/${actor.slug}`"
|
||||
:href="`/actor/${actor.id}/${actor.slug}?inspect`"
|
||||
target="_blank"
|
||||
class="nolink"
|
||||
>{{ actor.id }}</a>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { redirect } from 'vike/abort'; /* eslint-disable-line import/extensions */
|
||||
import markdownIt from 'markdown-it';
|
||||
import markdownItClass from '@toycode/markdown-it-class';
|
||||
|
||||
@@ -42,9 +43,13 @@ async function fetchReleases(pageContext) {
|
||||
|
||||
export async function onBeforeRender(pageContext) {
|
||||
const tagSlug = pageContext.routeParams.tagSlug;
|
||||
const [tag] = await fetchTagsById([tagSlug], {}, pageContext.user, { restriction: pageContext.restriction });
|
||||
|
||||
const [[tag], tagReleases, campaigns] = await Promise.all([
|
||||
fetchTagsById([tagSlug], {}, pageContext.user, { restriction: pageContext.restriction }),
|
||||
if (tag.aliasFor) {
|
||||
throw redirect(`/tag/${tag.aliasFor}`);
|
||||
}
|
||||
|
||||
const [tagReleases, campaigns] = await Promise.all([
|
||||
fetchReleases(pageContext),
|
||||
getRandomCampaigns([
|
||||
{ tagSlugs: [tagSlug], minRatio: 0.75, maxRatio: 1.25 },
|
||||
|
||||
Reference in New Issue
Block a user