Skip to content

Commit

Permalink
fix(layout): 🐛 fix exported functions from pages
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydrichards committed Jun 5, 2023
1 parent d0c2321 commit 14a8566
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
6 changes: 2 additions & 4 deletions src/app/(posts)/blogs/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ export interface BlogPageProps {
};
}

export async function getBlogFromParams(slug: string) {
const getBlogFromParams = async (slug: string) => {
const blog = allBlogs.find((blog) => blog.slugAsParams === slug);

if (!blog) notFound();

return blog;
}
};

export async function generateMetadata({
params,
Expand Down
4 changes: 1 addition & 3 deletions src/app/(posts)/labs/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ export interface LabPageProps {
};
}

export async function getLabFromParams(slug: string) {
const getLabFromParams = async (slug: string)=> {
const lab = allLabs.find((lab) => lab.slugAsParams === slug);

if (!lab) notFound();

return lab;
}

Expand Down
13 changes: 9 additions & 4 deletions src/app/@modal/(.)projects/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import {
ProjectPageProps,
getProjectFromParams,
} from "@/app/projects/[slug]/page";
import { ProjectPageProps } from "@/app/projects/[slug]/page";
import { Mdx } from "@/components/Mdx";
import { Modal } from "@/components/layout/modal/Modal";
import { allProjects } from "contentlayer/generated";
import Link from "next/link";
import { notFound } from "next/navigation";

const getProjectFromParams = async (slug: string) => {
const project = allProjects.find((project) => project.slugAsParams === slug);
if (!project) notFound();
return project;
};

const ProjectModal = async ({ params }: ProjectPageProps) => {
const project = await getProjectFromParams(params.slug);
Expand Down
13 changes: 9 additions & 4 deletions src/app/@modal/_(.)blogs/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import {
BlogPageProps,
getBlogFromParams,
} from "@/app/(posts)/blogs/[slug]/page";
import { BlogPageProps } from "@/app/(posts)/blogs/[slug]/page";
import { Mdx } from "@/components/Mdx";
import { Modal } from "@/components/layout/modal/Modal";
import { allBlogs } from "contentlayer/generated";
import Link from "next/link";
import { notFound } from "next/navigation";

const getBlogFromParams = async (slug: string) => {
const blog = allBlogs.find((blog) => blog.slugAsParams === slug);
if (!blog) notFound();
return blog;
};

const BlogModal = async ({ params }: BlogPageProps) => {
const blog = await getBlogFromParams(params.slug);
Expand Down
10 changes: 9 additions & 1 deletion src/app/@modal/_(.)labs/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { LabPageProps, getLabFromParams } from "@/app/(posts)/labs/[slug]/page";
import { LabPageProps } from "@/app/(posts)/labs/[slug]/page";
import { Mdx } from "@/components/Mdx";
import { Modal } from "@/components/layout/modal/Modal";
import { allLabs } from "contentlayer/generated";
import Link from "next/link";
import { notFound } from "next/navigation";

const getLabFromParams = async (slug: string) => {
const lab = allLabs.find((lab) => lab.slugAsParams === slug);
if (!lab) notFound();
return lab;
};

const LabModal = async ({ params }: LabPageProps) => {
const lab = await getLabFromParams(params.slug);
Expand Down
6 changes: 2 additions & 4 deletions src/app/projects/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ export interface ProjectPageProps {
};
}

export async function getProjectFromParams(slug: string) {
const getProjectFromParams = async (slug: string) => {
const project = allProjects.find((project) => project.slugAsParams === slug);

if (!project) notFound();

return project;
}
};

export async function generateMetadata({
params,
Expand Down

1 comment on commit 14a8566

@vercel
Copy link

@vercel vercel bot commented on 14a8566 Jun 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.