feat: refactor whole bunch of stuff
This commit is contained in:
@@ -1,18 +1,18 @@
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { MainLayout } from "@components/layouts/main.tsx";
|
||||
import { Article } from "@lib/resource/articles.ts";
|
||||
import { KMenu } from "@islands/KMenu.tsx";
|
||||
import { YoutubePlayer } from "@components/Youtube.tsx";
|
||||
import { HashTags } from "@components/HashTags.tsx";
|
||||
import { isYoutubeLink } from "@lib/string.ts";
|
||||
import { removeImage, renderMarkdown } from "@lib/documents.ts";
|
||||
import { removeImage, renderMarkdown } from "@lib/markdown.ts";
|
||||
import { RedirectSearchHandler } from "@islands/Search.tsx";
|
||||
import PageHero from "@components/PageHero.tsx";
|
||||
import { Star } from "@components/Stars.tsx";
|
||||
import { MetaTags } from "@components/MetaTags.tsx";
|
||||
import { fetchResource } from "@lib/marka.ts";
|
||||
import { fetchResource } from "@lib/marka/index.ts";
|
||||
import { ArticleResource } from "@lib/marka/schema.ts";
|
||||
|
||||
export const handler: Handlers<{ article: Article; session: unknown }> = {
|
||||
export const handler: Handlers<{ article: ArticleResource; session: unknown }> = {
|
||||
async GET(_, ctx) {
|
||||
const article = await fetchResource(`articles/${ctx.params.name}.md`);
|
||||
if (!article) {
|
||||
@@ -30,11 +30,9 @@ export default function Greet(
|
||||
const { author = "", date = "", articleBody = "" } = article?.content || {};
|
||||
|
||||
const content = renderMarkdown(
|
||||
removeImage(articleBody, article.content.image),
|
||||
removeImage(articleBody, article.image?.url),
|
||||
);
|
||||
|
||||
console.log({ article });
|
||||
|
||||
return (
|
||||
<MainLayout
|
||||
url={props.url}
|
||||
@@ -46,8 +44,8 @@ export default function Greet(
|
||||
<MetaTags resource={article} />
|
||||
|
||||
<PageHero
|
||||
image={article.content.image}
|
||||
thumbnail={article.content.thumbnail}
|
||||
image={article.image?.url}
|
||||
thumbhash={article.image?.thumbhash}
|
||||
>
|
||||
<PageHero.Header>
|
||||
<PageHero.BackLink href="/articles" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { MainLayout } from "@components/layouts/main.tsx";
|
||||
import { Article } from "@lib/resource/articles.ts";
|
||||
import { type ArticleResource } from "@lib/marka/schema.ts";
|
||||
import { KMenu } from "@islands/KMenu.tsx";
|
||||
import { Grid } from "@components/Grid.tsx";
|
||||
import { IconArrowLeft } from "@components/icons.tsx";
|
||||
@@ -9,13 +9,13 @@ import { parseResourceUrl, searchResource } from "@lib/search.ts";
|
||||
import { GenericResource } from "@lib/types.ts";
|
||||
import { ResourceCard } from "@components/Card.tsx";
|
||||
import { Link } from "@islands/Link.tsx";
|
||||
import { fetchResource } from "@lib/marka.ts";
|
||||
import { listResources } from "@lib/marka/index.ts";
|
||||
|
||||
export const handler: Handlers<
|
||||
{ articles: Article[] | null; searchResults?: GenericResource[] }
|
||||
{ articles: ArticleResource[] | null; searchResults?: GenericResource[] }
|
||||
> = {
|
||||
async GET(req, ctx) {
|
||||
const { content: articles } = await fetchResource("articles");
|
||||
const articles = await listResources("articles");
|
||||
const searchParams = parseResourceUrl(req.url);
|
||||
const searchResults = searchParams &&
|
||||
await searchResource({ ...searchParams, types: ["article"] });
|
||||
@@ -25,7 +25,7 @@ export const handler: Handlers<
|
||||
|
||||
export default function Greet(
|
||||
props: PageProps<
|
||||
{ articles: Article[] | null; searchResults: GenericResource[] }
|
||||
{ articles: ArticleResource[] | null; searchResults: GenericResource[] }
|
||||
>,
|
||||
) {
|
||||
const { articles, searchResults } = props.data;
|
||||
|
||||
Reference in New Issue
Block a user