feat: only show edit button when logged in

This commit is contained in:
2023-08-09 15:47:37 +02:00
parent 936ed32b11
commit f066b4e5e4
6 changed files with 46 additions and 22 deletions

View File

@ -10,12 +10,14 @@ import { RedirectSearchHandler } from "@islands/Search.tsx";
export const handler: Handlers<Movie | null> = {
async GET(_, ctx) {
const movie = await getMovie(ctx.params.name);
return ctx.render(movie);
return ctx.render({ movie, session: ctx.state.session });
},
};
export default function Greet(props: PageProps<Movie>) {
const movie = props.data;
export default function Greet(
props: PageProps<{ movie: Movie; session: Record<string, string> }>,
) {
const { movie, session } = props.data;
const { author = "", date = "" } = movie.meta;
@ -28,7 +30,9 @@ export default function Greet(props: PageProps<Movie>) {
<RecipeHero
data={movie}
subline={[author, date.toString()]}
editLink={`https://notes.max-richter.dev/Media/movies/${movie.id}`}
editLink={session
? `https://notes.max-richter.dev/Media/movies/${movie.id}`
: ""}
backlink="/movies"
/>
{movie.tags.length > 0 && (