refactor: code refactor

This commit is contained in:
Andrea 2023-03-02 08:43:46 +01:00
parent bd16bc4fcf
commit b0672af566
No known key found for this signature in database
GPG Key ID: 4594610B9C8F91C5
7 changed files with 230 additions and 942 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
node_modules

View File

@ -1,9 +1,13 @@
FROM node:alpine FROM node:alpine
COPY . /src WORKDIR /app
WORKDIR /src COPY ./package*.json /app
RUN npm install && npm run build RUN npm install
COPY . /app
RUN npm run build
CMD ["npm", "run", "start"] CMD ["npm", "run", "start"]

View File

@ -64,3 +64,28 @@ export function CatchBoundary() {
</html> </html>
); );
} }
export function ErrorBoundary() {
return (
<html lang="en">
<head>
<Meta />
<Links />
</head>
<body className="bg-[#202020] text-[#d6d6d6] font-['monospace']">
<div className="flex flex-col items-center justify-around h-[100vh]">
<div>
<div className="text-center text-[#ffff00] text-[10vw] font-bold">
Something bad happened
</div>
<div className="text-center">
<Link to="/" className="hover:text-[#e6c2bf]">
Home
</Link>
</div>
</div>
</div>
</body>
</html>
);
}

View File

@ -1,3 +0,0 @@
export function PostsWrapper({ children }: React.PropsWithChildren) {
return <div className="mt-5 px-10 w-max">{children}</div>;
}

View File

@ -2,7 +2,6 @@ import { Link, useLoaderData } from "@remix-run/react";
import { findPosts } from "~/models/posts.server"; import { findPosts } from "~/models/posts.server";
import { EmptyState } from "./EmptyState"; import { EmptyState } from "./EmptyState";
import { Post } from "./Post"; import { Post } from "./Post";
import { PostsWrapper } from "./PostsWrapper";
export const loader = async () => { export const loader = async () => {
return findPosts(); return findPosts();
@ -19,11 +18,11 @@ export default function () {
<span>Here I blog about whatever get my attention</span> <span>Here I blog about whatever get my attention</span>
</div> </div>
{posts.length > 0 ? ( {posts.length > 0 ? (
<PostsWrapper> <div className="mt-5 px-10 w-max">
{posts.map((post) => ( {posts.map((post, i) => (
<Post {...post} /> <Post {...post} key={i} />
))} ))}
</PostsWrapper> </div>
) : ( ) : (
<EmptyState /> <EmptyState />
)} )}

1116
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,17 +13,10 @@
"@remix-run/node": "^1.13.0", "@remix-run/node": "^1.13.0",
"@remix-run/react": "^1.13.0", "@remix-run/react": "^1.13.0",
"@remix-run/serve": "^1.13.0", "@remix-run/serve": "^1.13.0",
"esbuild": "0.17.10",
"front-matter": "4.0.2",
"isbot": "^3.6.5", "isbot": "^3.6.5",
"mdx-bundler": "9.2.1", "mdx-bundler": "9.2.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"rehype-autolink-headings": "6.1.1",
"rehype-highlight": "6.0.0",
"rehype-slug": "5.1.0",
"rehype-toc": "3.0.2",
"remark-gfm": "3.0.1",
"shiki": "^0.14.1" "shiki": "^0.14.1"
}, },
"devDependencies": { "devDependencies": {