diff --git a/src/app/(main)/page.tsx b/src/app/(main)/page.tsx index 98d1a27..17433f9 100644 --- a/src/app/(main)/page.tsx +++ b/src/app/(main)/page.tsx @@ -1,16 +1,7 @@ -import Link from "next/link"; -import config from "../../../keystatic.config"; -import CoverImage from "@/components/CoverImage"; -import { Badge } from "@/components/ui/Badge"; -import { LinkTag } from "@/components/ui/typography/LinkTag"; -import { linkedInProfile } from "@/lib/constants"; -import { formatDateRange } from "@/lib/dates"; -import { createReader } from "@keystatic/core/reader"; -import { DocumentRenderer } from "@keystatic/core/renderer"; -import dayjs from "dayjs"; -import { TbExternalLink } from "react-icons/tb"; - -const reader = createReader(process.cwd(), config); +import About from "@/components/homepage/About"; +import Experiences from "@/components/homepage/Experiences"; +import Posts from "@/components/homepage/Posts"; +import Projects from "@/components/homepage/Projects"; export const metadata = { alternates: { @@ -18,183 +9,13 @@ export const metadata = { }, }; -const Page = async () => { - const aboutData = await reader.singletons.about.read({ - resolveLinkedFiles: true, - }); - const experiencesData = await reader.collections.experiences.all(); - - const sortedExperiencesDataByDate = experiencesData.sort((a, b) => - dayjs(b.entry.startDate).diff(dayjs(a.entry.startDate)) - ); - - const projectsData = await reader.collections.projects.all(); - - const postsData = await reader.collections.posts.all(); - - const sortedPostsData = postsData.sort((a, b) => - dayjs(b.entry.date).diff(dayjs(a.entry.date)) - ); - - const firstThreePosts = sortedPostsData.slice(0, 3); - +const Page = () => { return ( <> -
-

- About -

- - {aboutData && aboutData.description && ( -
- -
- )} -
- -
-

- Experiences -

-
    - {sortedExperiencesDataByDate.map((experience) => ( -
  1. - - -
    - {formatDateRange( - experience.entry.startDate, - experience.entry.endDate.value - )} -
    -
    -
    -

    - {experience.entry.title} -

    -

    - {experience.entry.description} -

    -
    -
    - {experience.entry.tags.map((tag) => ( - - {tag} - - ))} -
    -
    -
    -
  2. - ))} -
- - - View More at LinkedIn - - -
-
-

- Projects -

-
    - {projectsData.map((project) => ( -
  1. - - -
    - {project.entry.image && ( - - )} -
    -
    -
    -

    - {project.entry.name} -

    -

    - {project.entry.description} -

    -
    -
    -
    -
  2. - ))} -
-
-
-

- Posts -

-
    - {firstThreePosts.map((post) => ( -
  1. - - -
    -
    -

    - {post.entry.title} -

    -

    - {post.entry.description} -

    -
    -
    - -
  2. - ))} -
- - - - More Posts - - -
+ + + + ); }; diff --git a/src/app/(main)/posts/page.tsx b/src/app/(main)/posts/page.tsx index 3ce8232..009dc22 100644 --- a/src/app/(main)/posts/page.tsx +++ b/src/app/(main)/posts/page.tsx @@ -43,48 +43,46 @@ const Page = async () => { dayjs(b.entry.date).diff(dayjs(a.entry.date)) ); return ( - <> -
- - - - Back - - +
+ + + + Back + + -

Posts

-
    - {sortedPostsData.map((post) => ( -
  1. - - -
    -
    -

    - {post.entry.title} -

    -

    - {post.entry.description} -

    -
    +

    Posts

    +
      + {sortedPostsData.map((post) => ( +
    1. + + +
      +
      +

      + {post.entry.title} +

      +

      + {post.entry.description} +

      - -
    2. - ))} -
    -
- + + + + ))} + +
); }; diff --git a/src/components/homepage/About.tsx b/src/components/homepage/About.tsx new file mode 100644 index 0000000..19a23a5 --- /dev/null +++ b/src/components/homepage/About.tsx @@ -0,0 +1,29 @@ +import config from "../../../keystatic.config"; +import { createReader } from "@keystatic/core/reader"; +import { DocumentRenderer } from "@keystatic/core/renderer"; + +const reader = createReader(process.cwd(), config); + +const About = async () => { + const aboutData = await reader.singletons.about.read({ + resolveLinkedFiles: true, + }); + + return ( +
+

+ About +

+ + {aboutData && aboutData.description && ( +
+ +
+ )} +
+ ); +}; + +export default About; diff --git a/src/components/homepage/Experiences.tsx b/src/components/homepage/Experiences.tsx new file mode 100644 index 0000000..63e1f23 --- /dev/null +++ b/src/components/homepage/Experiences.tsx @@ -0,0 +1,84 @@ +import config from "../../../keystatic.config"; +import { Badge } from "@/components/ui/Badge"; +import { LinkTag } from "@/components/ui/typography/LinkTag"; +import { linkedInProfile } from "@/lib/constants"; +import { formatDateRange } from "@/lib/dates"; +import { createReader } from "@keystatic/core/reader"; +import dayjs from "dayjs"; +import { TbExternalLink } from "react-icons/tb"; + +const reader = createReader(process.cwd(), config); + +const Experiences = async () => { + const experiencesData = await reader.collections.experiences.all(); + + const sortedExperiencesDataByDate = experiencesData.sort((a, b) => + dayjs(b.entry.startDate).diff(dayjs(a.entry.startDate)) + ); + + return ( +
+

+ Experiences +

+
    + {sortedExperiencesDataByDate.map((experience) => ( +
  1. + + +
    + {formatDateRange( + experience.entry.startDate, + experience.entry.endDate.value + )} +
    +
    +
    +

    + {experience.entry.title} +

    +

    + {experience.entry.description} +

    +
    +
    + {experience.entry.tags.map((tag) => ( + + {tag} + + ))} +
    +
    +
    +
  2. + ))} +
+ + + View More at LinkedIn + + +
+ ); +}; + +export default Experiences; diff --git a/src/components/homepage/Posts.tsx b/src/components/homepage/Posts.tsx new file mode 100644 index 0000000..a01c53e --- /dev/null +++ b/src/components/homepage/Posts.tsx @@ -0,0 +1,59 @@ +import Link from "next/link"; +import config from "../../../keystatic.config"; +import { createReader } from "@keystatic/core/reader"; +import dayjs from "dayjs"; + +const reader = createReader(process.cwd(), config); + +const Posts = async () => { + const postsData = await reader.collections.posts.all(); + + const sortedPostsData = postsData.sort((a, b) => + dayjs(b.entry.date).diff(dayjs(a.entry.date)) + ); + + const firstThreePosts = sortedPostsData.slice(0, 3); + + return ( +
+

+ Posts +

+
    + {firstThreePosts.map((post) => ( +
  1. + + +
    +
    +

    + {post.entry.title} +

    +

    + {post.entry.description} +

    +
    +
    + +
  2. + ))} +
+ + + + More Posts + + +
+ ); +}; + +export default Posts; diff --git a/src/components/homepage/Projects.tsx b/src/components/homepage/Projects.tsx new file mode 100644 index 0000000..e454e02 --- /dev/null +++ b/src/components/homepage/Projects.tsx @@ -0,0 +1,56 @@ +import config from "../../../keystatic.config"; +import CoverImage from "@/components/CoverImage"; +import { createReader } from "@keystatic/core/reader"; + +const reader = createReader(process.cwd(), config); + +const Projects = async () => { + const projectsData = await reader.collections.projects.all(); + + return ( +
+

+ Projects +

+
    + {projectsData.map((project) => ( +
  1. + + +
    + {project.entry.image && ( + + )} +
    +
    +
    +

    + {project.entry.name} +

    +

    + {project.entry.description} +

    +
    +
    +
    +
  2. + ))} +
+
+ ); +}; + +export default Projects;