feat: only show edit button when logged in
This commit is contained in:
parent
936ed32b11
commit
f066b4e5e4
@ -5,9 +5,12 @@ export const HashTags = ({ tags }: { tags: string[] }) => {
|
||||
>
|
||||
{tags.map((t) => {
|
||||
return (
|
||||
<span class="bg-gray-700 text-white p-2 rounded-xl text-sm">
|
||||
<a
|
||||
class="bg-gray-700 text-white p-2 rounded-xl text-sm"
|
||||
href={`/?q=%23${t}`}
|
||||
>
|
||||
#{t}
|
||||
</span>
|
||||
</a>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
@ -1,11 +1,16 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { BadRequestError } from "@lib/errors.ts";
|
||||
import { AccessDeniedError, BadRequestError } from "@lib/errors.ts";
|
||||
import { getTypeSenseClient } from "@lib/typesense.ts";
|
||||
import { json } from "@lib/helpers.ts";
|
||||
import { extractHashTags } from "@lib/string.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET(req, _ctx) {
|
||||
async GET(req, ctx) {
|
||||
const session = ctx.state.session;
|
||||
if (!session) {
|
||||
throw new AccessDeniedError();
|
||||
}
|
||||
|
||||
const url = new URL(req.url);
|
||||
let query = url.searchParams.get("q");
|
||||
if (!query) {
|
||||
|
@ -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 && (
|
||||
|
@ -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 && (
|
||||
|
@ -11,12 +11,14 @@ import { KMenu } from "@islands/KMenu.tsx";
|
||||
export const handler: Handlers<Recipe | null> = {
|
||||
async GET(_, ctx) {
|
||||
const recipe = await getRecipe(ctx.params.name);
|
||||
return ctx.render(recipe);
|
||||
return ctx.render({ recipe, session: ctx.state.session });
|
||||
},
|
||||
};
|
||||
|
||||
export default function Greet(props: PageProps<Recipe>) {
|
||||
const recipe = props.data;
|
||||
export default function Greet(
|
||||
props: PageProps<{ recipe: Recipe; session: Record<string, string> }>,
|
||||
) {
|
||||
const { recipe, session } = props.data;
|
||||
|
||||
const portion = recipe.meta?.portion;
|
||||
const amount = useSignal(portion || 1);
|
||||
@ -36,7 +38,9 @@ export default function Greet(props: PageProps<Recipe>) {
|
||||
<RecipeHero
|
||||
data={recipe}
|
||||
backlink="/recipes"
|
||||
editLink={`https://notes.max-richter.dev/Recipes/${recipe.id}`}
|
||||
editLink={session
|
||||
? `https://notes.max-richter.dev/Recipes/${recipe.id}`
|
||||
: ""}
|
||||
subline={subline}
|
||||
/>
|
||||
<div class="px-8 text-white mt-10">
|
||||
|
@ -9,13 +9,15 @@ import { KMenu } from "@islands/KMenu.tsx";
|
||||
|
||||
export const handler: Handlers<Series | null> = {
|
||||
async GET(_, ctx) {
|
||||
const series = await getSeries(ctx.params.name);
|
||||
return ctx.render(series);
|
||||
const serie = await getSeries(ctx.params.name);
|
||||
return ctx.render({ serie, session: ctx.state.session });
|
||||
},
|
||||
};
|
||||
|
||||
export default function Greet(props: PageProps<Series>) {
|
||||
const serie = props.data;
|
||||
export default function Greet(
|
||||
props: PageProps<{ serie: Series; session: Record<string, string> }>,
|
||||
) {
|
||||
const { serie, session } = props.data;
|
||||
|
||||
const { author = "", date = "" } = serie.meta;
|
||||
|
||||
@ -28,7 +30,9 @@ export default function Greet(props: PageProps<Series>) {
|
||||
<RecipeHero
|
||||
data={serie}
|
||||
subline={[author, date.toString()]}
|
||||
editLink={`https://notes.max-richter.dev/Media/series/${serie.id}`}
|
||||
editLink={session
|
||||
? `https://notes.max-richter.dev/Media/series/${serie.id}`
|
||||
: ""}
|
||||
backlink="/series"
|
||||
/>
|
||||
{serie.tags.length > 0 && (
|
||||
|
Loading…
x
Reference in New Issue
Block a user