Redirecting aliased actors and tags.

This commit is contained in:
2026-07-07 01:05:18 +02:00
parent a94c24581f
commit 1f5bbb6ce5
7 changed files with 21 additions and 7 deletions

View File

@@ -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([

View File

@@ -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>

View File

@@ -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 },