remove old requirements; build fixes
This commit is contained in:
@@ -1,43 +1,35 @@
|
||||
import BlogPostController from "@/server/controllers/blogpost.controller";
|
||||
import Image from "next/image";
|
||||
import { MDXRemote } from "next-mdx-remote";
|
||||
import { serialize } from "next-mdx-remote/serialize";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
export default async function PostById({ params }: { params: { postid: string }}) {
|
||||
const { postid } = params;
|
||||
const controller = new BlogPostController();
|
||||
|
||||
console.log({ postid });
|
||||
|
||||
const post = await controller.getByID(postid);
|
||||
|
||||
if (!post) notFound();
|
||||
|
||||
const mdxSource = await serialize(post.content);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Post {postid}</h1>
|
||||
<p>Coming soon...</p>
|
||||
|
||||
{ post && (
|
||||
<article>
|
||||
<h2>{post.title}</h2>
|
||||
<p>{post.author}</p>
|
||||
<p>{post.posted.toDateString()}</p>
|
||||
{ post.updated ? <p>{post.updated.toDateString()}</p> : null }
|
||||
<article>
|
||||
<h1>{post.title}</h1>
|
||||
<p>{post.author}</p>
|
||||
{ post.written && <p>{post.written.toLocaleDateString()}</p> }
|
||||
|
||||
{ post.images && post.images.map((src, idx) => (
|
||||
<Image key={idx} src={src} alt={`attached media for post ${post.title}`} />
|
||||
))}
|
||||
|
||||
<hr />
|
||||
|
||||
<p>{post.content}</p>
|
||||
|
||||
<div id="category-list">
|
||||
{ post.tags?.map((tag, idx) => {
|
||||
return (
|
||||
<div key={idx}>
|
||||
<a href={`/log?category=${tag}`}>{tag}</a>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</article>
|
||||
)}
|
||||
<hr />
|
||||
|
||||
<MDXRemote {...mdxSource} />
|
||||
</article>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
8
components/Log/PostComponent.tsx
Normal file
8
components/Log/PostComponent.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
// import { MDXRemote } from "next-mdx-remote";
|
||||
// import { serialize } from "next-mdx-remote/serialize";
|
||||
// import { BlogPost } from "@/server/db/schema";
|
||||
|
||||
// export default async function PostComponent(post: BlogPost) {
|
||||
// const mdxSource = await serialize(post.content);
|
||||
// return <MDXRemote />
|
||||
// }
|
||||
8
env.mjs
8
env.mjs
@@ -9,10 +9,6 @@ const env = createEnv({
|
||||
MONGO_USER: z.string().optional(),
|
||||
MONGO_PASSWORD: z.string().optional(),
|
||||
|
||||
POSTGRES_URL: z.string().url(),
|
||||
POSTGRES_USER: z.string(),
|
||||
POSTGRES_PASSWORD: z.string(),
|
||||
|
||||
S3_ENDPOINT: z.string().url(),
|
||||
S3_REGION: z.string(),
|
||||
S3_ACCESS_KEY: z.string(),
|
||||
@@ -22,10 +18,6 @@ const env = createEnv({
|
||||
KV_URL: z.string(),
|
||||
},
|
||||
runtimeEnv: {
|
||||
POSTGRES_URL: process.env.POSTGRES_URL,
|
||||
POSTGRES_USER: process.env.POSTGRES_USER,
|
||||
POSTGRES_PASSWORD: process.env.POSTGRES_PASSWORD,
|
||||
|
||||
MONGO_URL: process.env.MONGO_URL,
|
||||
MONGO_USER: process.env.MONGO_USER,
|
||||
MONGO_PASSWORD: process.env.MONGO_PASSWORD,
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
"ioredis": "^5.3.2",
|
||||
"mongodb": "^6.3.0",
|
||||
"next": "^14.0.1",
|
||||
"next-mdx-remote": "^4.4.1",
|
||||
"pg": "^8.11.3",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createDBClient } from '../db/createClient';
|
||||
import { Maybe } from '@/util/helpers';
|
||||
import { ParseParams } from 'zod';
|
||||
import { MongoClient, WithId, Filter, InsertOneResult } from 'mongodb';
|
||||
import { MongoClient, WithId, ObjectId, InsertOneResult, Filter } from 'mongodb';
|
||||
|
||||
type FullParserType<T extends { [key: string]: any }> = (data: any, params?: Partial<ParseParams>) => T;
|
||||
|
||||
@@ -12,8 +12,8 @@ type ControllerOptions<T extends { [key: string]: any }> = {
|
||||
|
||||
export default abstract class BaseController<T extends { _id?: any, [key: string]: any }> {
|
||||
protected client: MongoClient
|
||||
collectionName: string
|
||||
parse: FullParserType<T>
|
||||
protected collectionName: string
|
||||
protected parse: FullParserType<T>
|
||||
|
||||
constructor(options: ControllerOptions<T>) {
|
||||
this.collectionName = options.tableName;
|
||||
@@ -27,7 +27,7 @@ export default abstract class BaseController<T extends { _id?: any, [key: string
|
||||
try {
|
||||
// we'll enable cache here later
|
||||
await this.client.connect();
|
||||
result = await this.client.db().collection<T>(this.collectionName)
|
||||
result = await this.client.db('mikayladotdev').collection<T>(this.collectionName)
|
||||
.find()
|
||||
.toArray();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user