sendou.ink/app/routes/a.tsx
Kalle 34ca290bdd
Redesign (#1179)
* Remove light mode

* Trim header

* New front page initial

* Get rid of build layout

* Breadcrumbs

* Desktop side nav

* Overhaul colors

* Add breadcrumbs

* New sub nav style

* Front page action buttons

* Add back add new build button

* Add articles page with icon

* Minor Object damage page layout tweaks

* Remove one unnecessary render from object damage

* Fix wrong link in article page

* Profile -> My Page in header

* Log in/out buttons in front

* Add drawings to front page

* Remove unnecessary comment
2022-12-05 16:05:51 +02:00

56 lines
1.6 KiB
TypeScript

import { Main } from "~/components/Main";
import type { LinksFunction } from "@remix-run/node";
import { json } from "@remix-run/node";
import { mostRecentArticles } from "~/modules/articles";
import styles from "~/styles/front.css";
import { useTranslation } from "~/hooks/useTranslation";
import type { SendouRouteHandle } from "~/utils/remix";
import { articlePage, ARTICLES_MAIN_PAGE, navIconUrl } from "~/utils/urls";
import { Link, useLoaderData } from "@remix-run/react";
const MAX_ARTICLES_COUNT = 100;
export const links: LinksFunction = () => {
return [{ rel: "stylesheet", href: styles }];
};
export const handle: SendouRouteHandle = {
breadcrumb: () => ({
imgPath: navIconUrl("articles"),
href: ARTICLES_MAIN_PAGE,
type: "IMAGE",
}),
};
export const loader = async () => {
return json({
articles: await mostRecentArticles(MAX_ARTICLES_COUNT),
});
};
export default function ArticlesMainPage() {
const { t } = useTranslation(["common"]);
const data = useLoaderData<typeof loader>();
return (
<Main className="stack lg">
<ul className="articles-list">
{data.articles.map((article) => (
<li key={article.title}>
<Link
to={articlePage(article.slug)}
className="articles-list__title"
>
{article.title}
</Link>
<div className="text-xs text-lighter">
{t("common:articles.by", { author: article.author })} {" "}
<time>{article.dateString}</time>
</div>
</li>
))}
</ul>
</Main>
);
}