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

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