feat: add initial add article command
This commit is contained in:
51
routes/articles/[name].tsx
Normal file
51
routes/articles/[name].tsx
Normal file
@@ -0,0 +1,51 @@
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { MainLayout } from "@components/layouts/main.tsx";
|
||||
import { Article, getArticle } from "@lib/resource/articles.ts";
|
||||
import { RecipeHero } from "@components/RecipeHero.tsx";
|
||||
import { KMenu } from "@islands/KMenu.tsx";
|
||||
|
||||
export const handler: Handlers<Article | null> = {
|
||||
async GET(_, ctx) {
|
||||
const movie = await getArticle(ctx.params.name);
|
||||
return ctx.render(movie);
|
||||
},
|
||||
};
|
||||
|
||||
export default function Greet(props: PageProps<Article>) {
|
||||
const article = props.data;
|
||||
|
||||
const { author = "", date = "" } = article.meta;
|
||||
|
||||
console.log({ tags: article.tags });
|
||||
|
||||
return (
|
||||
<MainLayout url={props.url}>
|
||||
<RecipeHero
|
||||
data={article}
|
||||
subline={[author, date.toString()]}
|
||||
backlink="/articles"
|
||||
/>
|
||||
<KMenu type="main" context={article} />
|
||||
{article.tags.length &&
|
||||
(
|
||||
<div class="flex gap-2 px-8">
|
||||
{article.tags.map((t) => {
|
||||
return (
|
||||
<span class="bg-gray-700 text-white p-2 rounded-xl text-sm">
|
||||
#{t}
|
||||
</span>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
<div class="px-8 text-white mt-10">
|
||||
<pre
|
||||
class="whitespace-break-spaces"
|
||||
dangerouslySetInnerHTML={{ __html: article.content || "" }}
|
||||
>
|
||||
{article.content}
|
||||
</pre>
|
||||
</div>
|
||||
</MainLayout>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user