diff --git a/app/components/LinkWrapper.tsx b/app/components/LinkWrapper.tsx index 1b4c917..cac5de5 100644 --- a/app/components/LinkWrapper.tsx +++ b/app/components/LinkWrapper.tsx @@ -1,6 +1,6 @@ export function LinkWrapper({ children }: React.PropsWithChildren) { return ( -
+
{children}
); diff --git a/app/components/PostPreview.tsx b/app/components/PostPreview.tsx index c488f21..5f98406 100644 --- a/app/components/PostPreview.tsx +++ b/app/components/PostPreview.tsx @@ -11,14 +11,12 @@ export function PostPreview({ }: SerializeFrom) { const formattedDate = useFormattedDate(published); return ( -
+
-
+
{title}
{description}
-
- -
+
diff --git a/app/components/Title.tsx b/app/components/Title.tsx index 5a2fb7c..9d8abb9 100644 --- a/app/components/Title.tsx +++ b/app/components/Title.tsx @@ -1,9 +1,7 @@ export function Title({ children }: React.PropsWithChildren) { return ( -
-
- {children} -
+
+

{children}

); } diff --git a/app/hooks/useFormattedDate.ts b/app/hooks/useFormattedDate.ts index 5930ef2..b0790eb 100644 --- a/app/hooks/useFormattedDate.ts +++ b/app/hooks/useFormattedDate.ts @@ -2,5 +2,5 @@ export function useFormattedDate(_date: string) { const date = new Date(_date); const month = date.getUTCMonth().toString().padStart(2, "0"); const monthDate = date.getUTCDate().toString().padStart(2, "0"); - return `${date.getUTCFullYear()}/${month}/${monthDate}`; + return `${date.getUTCFullYear()}-${month}-${monthDate}`; } diff --git a/app/hooks/useMatch.ts b/app/hooks/useMatch.ts deleted file mode 100644 index edd31e3..0000000 --- a/app/hooks/useMatch.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { useMatches } from "@remix-run/react"; - -export function useMatch() { - const matches = useMatches(); - const { handle, ...rest } = matches[matches.length - 1]; - - if (handle == null) { - throw new Error(`handle is missing for ${rest.pathname}`); - } - - return { handle, ...rest } as unknown as typeof rest & { - handle: { to: string; text: string }; - }; -} diff --git a/app/routes/blog.$file.tsx b/app/routes/blog.$file.tsx index 83f2f30..6286652 100644 --- a/app/routes/blog.$file.tsx +++ b/app/routes/blog.$file.tsx @@ -57,12 +57,18 @@ export default function Post() { return ( <> - {title} -
- -
-
-
+
+ {title} + + ยท + + Go Back + + +
+ +
+
@@ -85,7 +91,7 @@ export default function Post() {
-
+
); } diff --git a/app/routes/blog._index.tsx b/app/routes/blog._index.tsx index 45354ec..eb92d09 100644 --- a/app/routes/blog._index.tsx +++ b/app/routes/blog._index.tsx @@ -1,13 +1,9 @@ -import { useLoaderData } from "@remix-run/react"; +import { Link, useLoaderData } from "@remix-run/react"; +import { LinkWrapper } from "~/components/LinkWrapper"; import { PostPreview } from "~/components/PostPreview"; import { Title } from "~/components/Title"; import { findPosts } from "~/utils/posts.server"; -export const handle = { - to: "/", - text: "Home", -}; - export const loader = () => { return findPosts(); }; @@ -17,8 +13,11 @@ export default function Blog() { return ( <> + + Home + Here I blog about whatever get my attention -
+
{posts.map((post) => ( ))} diff --git a/app/routes/blog.tsx b/app/routes/blog.tsx index 2e8f139..4751668 100644 --- a/app/routes/blog.tsx +++ b/app/routes/blog.tsx @@ -1,8 +1,5 @@ import type { MetaFunction } from "@remix-run/node"; -import { Link } from "@remix-run/react"; import { Outlet } from "react-router-dom"; -import { LinkWrapper } from "~/components/LinkWrapper"; -import { useMatch } from "~/hooks/useMatch"; export const meta: MetaFunction = () => { return [ @@ -21,13 +18,8 @@ export const meta: MetaFunction = () => { }; export default function BlogLayout() { - const { handle } = useMatch(); - return ( -
- - {handle.text} - +
); diff --git a/package.json b/package.json index 40a840c..34cfa71 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "start": "remix-serve ./build/server/index.js", "typecheck": "tsc", "lint": "biome lint", - "format": "biome format --write" + "format": "biome format --write", + "routes": "remix routes" }, "dependencies": { "@code-hike/mdx": "0.9.0",