refactor: code refactor

This commit is contained in:
Andrea 2024-09-25 10:11:37 +02:00
parent 73f0401565
commit ceb31f2bcc
No known key found for this signature in database
GPG Key ID: 4594610B9C8F91C5
3 changed files with 13 additions and 6 deletions

View File

@ -3,7 +3,9 @@ import { Link, useLoaderData } from "@remix-run/react";
import { getMDXComponent } from "mdx-bundler/client/index.js"; import { getMDXComponent } from "mdx-bundler/client/index.js";
import React from "react"; import React from "react";
import { FaEdit } from "react-icons/fa"; import { FaEdit } from "react-icons/fa";
import { Notbyai } from "~/components/Notbyai";
import { Title } from "~/components/Title"; import { Title } from "~/components/Title";
import { useFormattedDate } from "~/hooks";
import { getMdxFile } from "~/utils/posts.server"; import { getMdxFile } from "~/utils/posts.server";
export const handle = { export const handle = {
@ -47,19 +49,24 @@ export const meta: MetaFunction<typeof loader> = ({ data }) => {
export default function () { export default function () {
const { const {
code, code,
frontmatter: { title }, frontmatter: { title, published },
file, file,
} = useLoaderData<typeof loader>(); } = useLoaderData<typeof loader>();
const formattedDate = useFormattedDate(published);
const MdxComponent = React.useMemo(() => getMDXComponent(code), [code]); const MdxComponent = React.useMemo(() => getMDXComponent(code), [code]);
return ( return (
<div className="space-y-6"> <>
<Title>{title}</Title> <Title>{title}</Title>
<div className="text-center">
<time>{formattedDate}</time>
</div>
<div className="flex flex-col items-center"> <div className="flex flex-col items-center">
<div className="space-y-5 sm:w-full sm:px-5 lg:w-5/6 xl:w-1/3"> <div className="space-y-5 sm:w-full sm:px-5 lg:w-5/6 xl:w-1/3">
<div className="dark:prose-invert prose-a:no-underline prose-a:font-bold hover:prose-a:text-[#ffff00] prose-p:text-[#d6d6d6]"> <div className="dark:prose-invert prose-a:no-underline prose-a:font-bold hover:prose-a:text-[#ffff00] prose-p:text-[#d6d6d6]">
<MdxComponent /> <MdxComponent />
</div> </div>
<Notbyai />
<div> <div>
<Link <Link
to={`https://github.com/nullndr/website/edit/main/posts/${file}.mdx`} to={`https://github.com/nullndr/website/edit/main/posts/${file}.mdx`}
@ -73,6 +80,6 @@ export default function () {
</div> </div>
</div> </div>
</div> </div>
</div> </>
); );
} }

View File

@ -17,7 +17,7 @@ export default function () {
const posts = useLoaderData<typeof loader>(); const posts = useLoaderData<typeof loader>();
return ( return (
<div className="space-y-6"> <>
<Title>Here I blog about whatever get my attention</Title> <Title>Here I blog about whatever get my attention</Title>
{posts.length > 0 ? ( {posts.length > 0 ? (
<div className="flex flex-col items-center space-y-5"> <div className="flex flex-col items-center space-y-5">
@ -28,6 +28,6 @@ export default function () {
) : ( ) : (
<EmptyState /> <EmptyState />
)} )}
</div> </>
); );
} }

View File

@ -7,7 +7,7 @@ export default function () {
const { handle } = useMatch(); const { handle } = useMatch();
return ( return (
<div> <div className="space-y-6">
<LinkWrapper> <LinkWrapper>
<Link to={handle.to}>{handle.text}</Link> <Link to={handle.to}>{handle.text}</Link>
</LinkWrapper> </LinkWrapper>