From 806ef1ec90ab0140f8ab1e9eb364c8baf9a17818 Mon Sep 17 00:00:00 2001 From: Andrea Date: Wed, 1 Mar 2023 20:39:41 +0100 Subject: [PATCH] feat: add posts --- .gitignore | 4 +- Dockerfile | 9 + app/models/posts.server.ts | 23 + app/root.tsx | 2 + app/routes/_index.tsx | 59 +- app/routes/blog/EmptyState.tsx | 10 + app/routes/blog/Post.tsx | 30 +- app/routes/blog/PostsWrapper.tsx | 2 +- app/routes/blog/route.tsx | 35 +- app/routes/blog_.$id.tsx | 37 +- app/utils/db.server.ts | 21 + app/utils/posts.server.ts | 26 + package-lock.json | 4358 ++++++++++++++++++++++++------ package.json | 15 +- post/test.mdx | 8 + prisma/schema.prisma | 20 + remix.config.js | 1 + tsconfig.json | 8 +- 18 files changed, 3810 insertions(+), 858 deletions(-) create mode 100644 Dockerfile create mode 100644 app/models/posts.server.ts create mode 100644 app/routes/blog/EmptyState.tsx create mode 100644 app/utils/db.server.ts create mode 100644 app/utils/posts.server.ts create mode 100644 post/test.mdx create mode 100644 prisma/schema.prisma diff --git a/.gitignore b/.gitignore index f7b07d5..0e25bd2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ node_modules /public/build .env -app/tailwind.css \ No newline at end of file +app/tailwind.css + +prisma/dev.db \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..f9b5bd8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM node:alpine + +COPY . /src + +WORKDIR /src + +RUN npm install && npm run build + +CMD ["npm", "run", "start"] \ No newline at end of file diff --git a/app/models/posts.server.ts b/app/models/posts.server.ts new file mode 100644 index 0000000..3056dbd --- /dev/null +++ b/app/models/posts.server.ts @@ -0,0 +1,23 @@ +import { db } from "~/utils/db.server"; + +export const findPosts = async () => { + return db.post.findMany({ + select: { + id: true, + title: true, + description: true, + createdAt: true, + }, + orderBy: { + createdAt: "desc", + }, + }); +}; + +export const findPost = async (id: string) => { + return db.post.findUnique({ + where: { + id, + }, + }); +}; diff --git a/app/root.tsx b/app/root.tsx index b8893b7..3a22eae 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -1,3 +1,4 @@ +import codeHikeStyle from "@code-hike/mdx/dist/index.css"; import type { LinksFunction, MetaFunction } from "@remix-run/node"; import { Link, @@ -12,6 +13,7 @@ import stylesheet from "~/tailwind.css"; export const links: LinksFunction = () => [ { rel: "stylesheet", href: stylesheet }, + { rel: "stylesheet", href: codeHikeStyle }, ]; export const meta: MetaFunction = () => ({ diff --git a/app/routes/_index.tsx b/app/routes/_index.tsx index 6881955..9cf9159 100644 --- a/app/routes/_index.tsx +++ b/app/routes/_index.tsx @@ -8,6 +8,7 @@ import { FaTelegramPlane, FaTwitter, } from "react-icons/fa"; +import { IconContext } from "react-icons/lib"; import { MdEmail } from "react-icons/md"; export default function Index() { @@ -18,37 +19,35 @@ export default function Index() { $ echo "Hello, world!" | -