From 41ec9550bd9a147e6ce1fa321135e3d3d0ffc86e Mon Sep 17 00:00:00 2001 From: Alex Frantz Date: Sat, 23 Mar 2024 22:09:51 -0400 Subject: [PATCH] move projects to projects page --- src/components/ProjectsCard.tsx | 30 ++++++------ src/components/RootLayout.tsx | 36 ++++++-------- src/components/header.tsx | 2 +- src/pages/blog/[id].tsx | 66 -------------------------- src/pages/blog/create.tsx | 78 ------------------------------- src/pages/blog/index.tsx | 59 ----------------------- src/pages/index.tsx | 40 +--------------- src/pages/projects.tsx | 83 +++++++++++++++++++++++++++++++++ 8 files changed, 114 insertions(+), 280 deletions(-) delete mode 100644 src/pages/blog/[id].tsx delete mode 100644 src/pages/blog/create.tsx delete mode 100644 src/pages/blog/index.tsx create mode 100644 src/pages/projects.tsx diff --git a/src/components/ProjectsCard.tsx b/src/components/ProjectsCard.tsx index 253175c..b4f909b 100644 --- a/src/components/ProjectsCard.tsx +++ b/src/components/ProjectsCard.tsx @@ -10,27 +10,29 @@ type ProjectCardProps = { export default function ProjectCard(props: ProjectCardProps) { const technologies = props.technologies.map((v,k) => { - return

{v}

+ return
+
+ {v} +
+
}) return ( -
-
-
-

{props.name}

-
- {technologies} -
+
+
+

{props.name}

+
+ {technologies}
-
-

{props.description}

- -
+
+

{props.description}

+ +
-

Source

+

Source

-
+
) } \ No newline at end of file diff --git a/src/components/RootLayout.tsx b/src/components/RootLayout.tsx index 9c91405..b4788f6 100644 --- a/src/components/RootLayout.tsx +++ b/src/components/RootLayout.tsx @@ -28,34 +28,24 @@ export default function RootLayout({ children, protectedPage }: LayoutProps) {
) - } - - if (status === "unauthenticated") { + } else if (status === "unauthenticated") { Router.replace("/").catch(() => { console.error("Failed to reroute user!") }) - } else { return ( -
-
- -
- {children} -
-
-
+ <> ) } - } else { - return ( -
-
- -
- {children} -
-
-
- ) } + + return ( +
+
+ +
+ {children} +
+
+
+ ) } \ No newline at end of file diff --git a/src/components/header.tsx b/src/components/header.tsx index 01f36cd..b990718 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -10,7 +10,7 @@ export default function Header() {
- + { status === "authenticated" && { - console.error("Failed to reroute user!") - }) - } - } - - if (blogData) { - return ( - -
-

{blogData.name} { status == "authenticated" ? : ""}

- -
-
-
- - - {blogData.contents} - -
-
- ) - } else { - return ( - -
-

Well, that's not good..

-
- -
-

You've reached a page that doesn't exist. Lets fix that.

- - Head Home - -
-
- ) - } -} \ No newline at end of file diff --git a/src/pages/blog/create.tsx b/src/pages/blog/create.tsx deleted file mode 100644 index 12cfb00..0000000 --- a/src/pages/blog/create.tsx +++ /dev/null @@ -1,78 +0,0 @@ -// trpc api -import { api } from "@/utils/api"; -import {useState, useRef} from 'react'; -import Markdown from 'react-markdown' -import remarkGfm from 'remark-gfm' - -// components -import RootLayout from '@/components/RootLayout'; - -// types -import type { FormEvent } from "react"; - -export default function BlogCreatePage() { - const [textContent, setTextContent] = useState(null) - const [showMarkdown, setShowMarkdown] = useState(false) - - // element refs - const titleRef = useRef(null) - const tagRef = useRef(null) - const imageRef = useRef(null) - - // trpc mutation - const blogPostMutation = api.blog.create.useMutation() - - function handleElementUpdate(e: FormEvent) { - const textarea = e.target as HTMLTextAreaElement - setTextContent(textarea.value) - } - - function submitBlogPost() { - if (!textContent || textContent == "") { - console.error("No text provided") - return; - } - - if (!titleRef || !tagRef || !titleRef.current?.value || !tagRef.current?.value || titleRef.current?.value == "" || tagRef.current?.value == "") { - console.error("No title/tagline provided") - return; - } - - if (!imageRef?.current?.value || imageRef.current?.value == "") { - console.error("No image URL provided") - return - } - - const data = { - name: titleRef.current?.value, - tagline: tagRef.current?.value, - image: imageRef.current?.value, - contents: textContent, - } - - blogPostMutation.mutate(data) - } - - return ( - -
- -
- - { - showMarkdown ? - {textContent} - - :