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) => {
|
{tags.map((t) => {
|
||||||
return (
|
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}
|
#{t}
|
||||||
</span>
|
</a>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
import { Handlers } from "$fresh/server.ts";
|
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 { getTypeSenseClient } from "@lib/typesense.ts";
|
||||||
import { json } from "@lib/helpers.ts";
|
import { json } from "@lib/helpers.ts";
|
||||||
import { extractHashTags } from "@lib/string.ts";
|
import { extractHashTags } from "@lib/string.ts";
|
||||||
|
|
||||||
export const handler: Handlers = {
|
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);
|
const url = new URL(req.url);
|
||||||
let query = url.searchParams.get("q");
|
let query = url.searchParams.get("q");
|
||||||
if (!query) {
|
if (!query) {
|
||||||
|
@ -11,13 +11,15 @@ import { RedirectSearchHandler } from "@islands/Search.tsx";
|
|||||||
|
|
||||||
export const handler: Handlers<Article | null> = {
|
export const handler: Handlers<Article | null> = {
|
||||||
async GET(_, ctx) {
|
async GET(_, ctx) {
|
||||||
const movie = await getArticle(ctx.params.name);
|
const article = await getArticle(ctx.params.name);
|
||||||
return ctx.render(movie);
|
return ctx.render({ article, session: ctx.state.session });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Greet(props: PageProps<Article>) {
|
export default function Greet(
|
||||||
const article = props.data;
|
props: PageProps<{ article: Article; session: Record<string, string> }>,
|
||||||
|
) {
|
||||||
|
const { article, session } = props.data;
|
||||||
|
|
||||||
const { author = "", date = "" } = article.meta;
|
const { author = "", date = "" } = article.meta;
|
||||||
|
|
||||||
@ -34,7 +36,9 @@ export default function Greet(props: PageProps<Article>) {
|
|||||||
<RecipeHero
|
<RecipeHero
|
||||||
data={article}
|
data={article}
|
||||||
subline={[author, date.toString()]}
|
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"
|
backlink="/articles"
|
||||||
/>
|
/>
|
||||||
{article.tags.length > 0 && (
|
{article.tags.length > 0 && (
|
||||||
|
@ -10,12 +10,14 @@ import { RedirectSearchHandler } from "@islands/Search.tsx";
|
|||||||
export const handler: Handlers<Movie | null> = {
|
export const handler: Handlers<Movie | null> = {
|
||||||
async GET(_, ctx) {
|
async GET(_, ctx) {
|
||||||
const movie = await getMovie(ctx.params.name);
|
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>) {
|
export default function Greet(
|
||||||
const movie = props.data;
|
props: PageProps<{ movie: Movie; session: Record<string, string> }>,
|
||||||
|
) {
|
||||||
|
const { movie, session } = props.data;
|
||||||
|
|
||||||
const { author = "", date = "" } = movie.meta;
|
const { author = "", date = "" } = movie.meta;
|
||||||
|
|
||||||
@ -28,7 +30,9 @@ export default function Greet(props: PageProps<Movie>) {
|
|||||||
<RecipeHero
|
<RecipeHero
|
||||||
data={movie}
|
data={movie}
|
||||||
subline={[author, date.toString()]}
|
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"
|
backlink="/movies"
|
||||||
/>
|
/>
|
||||||
{movie.tags.length > 0 && (
|
{movie.tags.length > 0 && (
|
||||||
|
@ -11,12 +11,14 @@ import { KMenu } from "@islands/KMenu.tsx";
|
|||||||
export const handler: Handlers<Recipe | null> = {
|
export const handler: Handlers<Recipe | null> = {
|
||||||
async GET(_, ctx) {
|
async GET(_, ctx) {
|
||||||
const recipe = await getRecipe(ctx.params.name);
|
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>) {
|
export default function Greet(
|
||||||
const recipe = props.data;
|
props: PageProps<{ recipe: Recipe; session: Record<string, string> }>,
|
||||||
|
) {
|
||||||
|
const { recipe, session } = props.data;
|
||||||
|
|
||||||
const portion = recipe.meta?.portion;
|
const portion = recipe.meta?.portion;
|
||||||
const amount = useSignal(portion || 1);
|
const amount = useSignal(portion || 1);
|
||||||
@ -36,7 +38,9 @@ export default function Greet(props: PageProps<Recipe>) {
|
|||||||
<RecipeHero
|
<RecipeHero
|
||||||
data={recipe}
|
data={recipe}
|
||||||
backlink="/recipes"
|
backlink="/recipes"
|
||||||
editLink={`https://notes.max-richter.dev/Recipes/${recipe.id}`}
|
editLink={session
|
||||||
|
? `https://notes.max-richter.dev/Recipes/${recipe.id}`
|
||||||
|
: ""}
|
||||||
subline={subline}
|
subline={subline}
|
||||||
/>
|
/>
|
||||||
<div class="px-8 text-white mt-10">
|
<div class="px-8 text-white mt-10">
|
||||||
|
@ -9,13 +9,15 @@ import { KMenu } from "@islands/KMenu.tsx";
|
|||||||
|
|
||||||
export const handler: Handlers<Series | null> = {
|
export const handler: Handlers<Series | null> = {
|
||||||
async GET(_, ctx) {
|
async GET(_, ctx) {
|
||||||
const series = await getSeries(ctx.params.name);
|
const serie = await getSeries(ctx.params.name);
|
||||||
return ctx.render(series);
|
return ctx.render({ serie, session: ctx.state.session });
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Greet(props: PageProps<Series>) {
|
export default function Greet(
|
||||||
const serie = props.data;
|
props: PageProps<{ serie: Series; session: Record<string, string> }>,
|
||||||
|
) {
|
||||||
|
const { serie, session } = props.data;
|
||||||
|
|
||||||
const { author = "", date = "" } = serie.meta;
|
const { author = "", date = "" } = serie.meta;
|
||||||
|
|
||||||
@ -28,7 +30,9 @@ export default function Greet(props: PageProps<Series>) {
|
|||||||
<RecipeHero
|
<RecipeHero
|
||||||
data={serie}
|
data={serie}
|
||||||
subline={[author, date.toString()]}
|
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"
|
backlink="/series"
|
||||||
/>
|
/>
|
||||||
{serie.tags.length > 0 && (
|
{serie.tags.length > 0 && (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user