-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from lucasdale99/feature/add-post-creation
Feature/add post creation
- Loading branch information
Showing
18 changed files
with
103 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use server"; | ||
|
||
import { eq } from "drizzle-orm"; | ||
import { db } from "@/lib/db"; | ||
import { blogsTable } from "@/lib/schema"; | ||
|
||
export async function getBlog(slug: string) { | ||
try { | ||
const incomingSlug = slug.replace(/^\/+|\/+$/g, ""); | ||
|
||
const blogData = await db | ||
.select() | ||
.from(blogsTable) | ||
.where(eq(blogsTable.slug, `/${incomingSlug}`)); | ||
|
||
if (!blogData.length) { | ||
throw new Error("Blog not found"); | ||
} | ||
|
||
return blogData[0]; | ||
} catch (error) { | ||
console.error("Error fetching blog:", error); | ||
throw new Error("Failed to fetch blog"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use server"; | ||
import { db } from "@/lib/db"; | ||
import { blogsTable } from "@/lib/schema"; | ||
|
||
export async function getBlogs() { | ||
try { | ||
const blogs = await db.select().from(blogsTable).execute(); | ||
return blogs; | ||
} catch (error) { | ||
console.error("Error fetching blogs:", error); | ||
throw new Error("Failed to fetch blogs"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
"use server"; | ||
|
||
import { db } from "../../lib/db"; | ||
import { workExperienceTable } from "../../lib/schema"; | ||
|
||
export async function getWorkExperience() { | ||
try { | ||
const workExperience = await db | ||
.select() | ||
.from(workExperienceTable) | ||
.orderBy(workExperienceTable.startDate); | ||
|
||
return workExperience; | ||
} catch (error) { | ||
console.error("Error fetching work experience:", error); | ||
throw new Error("Failed to fetch work experience"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters