lovely. got a couple of partial implementations....
This commit is contained in:
parent
89ca4013fd
commit
89f526e9d9
14 changed files with 180 additions and 154 deletions
41
src/routes/(shell)/watch/[slug].tsx
Normal file
41
src/routes/(shell)/watch/[slug].tsx
Normal file
|
@ -0,0 +1,41 @@
|
|||
import { json, Params, query, redirect, RouteDefinition, useParams } from "@solidjs/router";
|
||||
import { createSlug, getEntry } from "~/features/content";
|
||||
import { Player } from "~/features/player";
|
||||
import { toSlug } from "~/utilities";
|
||||
|
||||
const healUrl = query(async (slug: string) => {
|
||||
const entry = await getEntry(slug.slice(slug.lastIndexOf('-') + 1));
|
||||
|
||||
if (entry === undefined) {
|
||||
return json(null, { status: 404 });
|
||||
}
|
||||
|
||||
const actualSlug = createSlug(entry);
|
||||
|
||||
if (slug === actualSlug) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw redirect(`/watch/${actualSlug}`);
|
||||
}, 'watch.heal');
|
||||
|
||||
interface ItemParams extends Params {
|
||||
title: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
export const route = {
|
||||
async preload({ params }) {
|
||||
await healUrl(params.slug);
|
||||
},
|
||||
} satisfies RouteDefinition;
|
||||
|
||||
export default function Item() {
|
||||
const params = useParams<ItemParams>();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Player id={params.id} />
|
||||
</>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue