Skip to content

Commit

Permalink
Merge pull request #30 from atlantabitdevs/28-events-and-posts
Browse files Browse the repository at this point in the history
Create events page and posts page
  • Loading branch information
jordan-bravo authored Jul 29, 2023
2 parents 4f62d8d + 7b78828 commit 09e0484
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 302 deletions.
33 changes: 33 additions & 0 deletions app/[contentType]/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { FC } from 'react'
import { allDocs } from 'contentlayer/generated'
import { Mdx } from '@/components/MDX-components'

interface PageProps {
params: {
slug: string
}
}

async function getDocFromParams(slug: string) {
const post = allDocs.find((post) => post.slugAsParams === slug)
return post
}

const page = async ({ params }: PageProps) => {
const post = await getDocFromParams(params.slug)

if (!post) {
return <div>404 sorry you poor bitdev</div>
}

console.log(post._raw.flattenedPath)

// return <div>{JSON.stringify(post)}</div>
return (
<div>
<Mdx code={post.body.code} />
</div>
)
}

export default page
32 changes: 32 additions & 0 deletions app/[contentType]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Link from 'next/link'
import {
ContentType,
getSortedMarkdownContent,
} from '../../lib/parse-markdown-files'
import MeetupName from '@/components/MeetupName'

export default function Posts({ params }: { params: any }) {
console.log('params.contentType: ', params.contentType)
const contentType = params.contentType
const allContentData = getSortedMarkdownContent(contentType)
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<MeetupName />
<h1>This is the Posts page, bruh</h1>
<Link href="/" style={{ textDecoration: 'underline' }}>
Home
</Link>
<ul>
{allContentData.map(({ id, date, title }) => (
<li className="post" key={id}>
{title}
<br />
{id}
<br />
{date}
</li>
))}
</ul>
</main>
)
}
26 changes: 0 additions & 26 deletions app/events/page.tsx

This file was deleted.

67 changes: 9 additions & 58 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,20 @@
import Link from 'next/link'
import { getSortedPostsData } from '../lib/parse-posts'
import MeetupName from '@/components/MeetupName'

const allPostsData = getSortedPostsData()

export default function Home({}) {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<MeetupName />
<h1>This is the home page, bruh</h1>
<Link href="/events">Events</Link>
<ul>
{allPostsData.map(({ id, date, title }) => (
<li className="post" key={id}>
{title}
<br />
{id}
<br />
{date}
</li>
))}
</ul>
<hr />
<h2>The Events component goes here.</h2>
<Link href="/events" style={{ textDecoration: 'underline' }}>
Click here to see all events...
</Link>
<h2>The Posts component goes here.</h2>
<Link href="/posts" style={{ textDecoration: 'underline' }}>
Click here to see all posts...
</Link>
</main>
)
}
// import Link from 'next/link'

// import { FC } from 'react'
// import {allDocs} from "contentlayer/generated"
// import { Mdx } from '@/components/MDX-components';

// interface PageProps {
// params: {
// slug: string
// }
// }

// // async fucntion getDocFromParams(slug: string) {
// // const post = allDocs.find((post) => post.slugAsParams === slug);
// // return post;
// // }

// async function getDocFromParams(slug: string) {
// // const post = allDocs.find((post) => post.slugAsParams === slug);
// const post = allDocs[0]
// // console.log(allDocs)
// return post;
// }

// const page = async ({ params }: PageProps) => {
// const post = await getDocFromParams(params.slug)

// console.log(post._raw.flattenedPath)

// // return <div>{JSON.stringify(post)}</div>
// return <div>
// {/* <Mdx code={post.body.code} /> */}
// {/* <Link href="/events/first-event">"hello"</Link> */}
// {/* <Link href="${post._raw.flattenedPath}">"hello"</Link> */}
// {/* <Link href="/"
// onClick=
// "location.href=this.href+post._raw.flattenedPath;return false;"
// >hello</Link> */}

// </div>
// }

// export default page
28 changes: 0 additions & 28 deletions app/posts/[slug]/page.tsx

This file was deleted.

151 changes: 0 additions & 151 deletions content/events/2023-07-25_testing-github-action.md

This file was deleted.

9 changes: 9 additions & 0 deletions content/events/2023-07-29.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
date: '2023-07-29.md'
title: 'Socratic Seminar for 2023-07-29'
type: Doc
---

This is the body of the event for 2023-07-29.

Bitcoin ipsum...
Empty file added content/pages/.gitkeep
Empty file.
Loading

0 comments on commit 09e0484

Please sign in to comment.