refactor: code refactor

This commit is contained in:
Andrea
2024-02-05 19:03:39 +01:00
parent 2e879d9c00
commit fa60885d85
7 changed files with 38 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
import type { LoaderFunctionArgs } from "@remix-run/node";
import type { LoaderFunctionArgs, MetaFunction } from "@remix-run/node";
import { useLoaderData } from "@remix-run/react";
import { getMDXComponent } from "mdx-bundler/client/index.js";
import React from "react";
@@ -20,6 +20,29 @@ export const loader = async ({ params }: LoaderFunctionArgs) => {
return getMdxFile(name);
};
export const meta: MetaFunction<typeof loader> = ({ data }) => {
if (data == null) {
return [];
}
const {
frontmatter: { title, description },
} = data;
return [
{
title,
},
{
property: "og:title",
content: title,
},
{
property: "description",
content: description,
},
];
};
export default function () {
const {
code,
@@ -28,13 +51,13 @@ export default function () {
const MdxComponent = React.useMemo(() => getMDXComponent(code), [code]);
return (
<>
<div className="space-y-5">
<Title>{title}</Title>
<BlogWrapper>
<div className="dark:prose-invert prose-a:no-underline prose-a:font-bold prose-a:text-[#ffff00] prose-p:text-[#d6d6d6]">
<MdxComponent />
</div>
</BlogWrapper>
</>
</div>
);
}