Skip to content

Commit

Permalink
Retrun 404 if page doesn't exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
y1mz committed Feb 3, 2024
1 parent edcfdf3 commit b98cc57
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions app/[page]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ import fs from "fs"
import Markdown from "markdown-to-jsx"
import matter from "gray-matter"
import { getPageMetadata } from "@/libs/getPageMetadata"
import { notFound } from "next/navigation"


import HeroSection from "@/components/hero-section"
const getPageContent = (page) => {
const folder = "public/pages/"
const file = `${folder}${page}.md`
const content = fs.readFileSync(file, "utf8")
const matterResult = matter(content)
return matterResult
try {
const folder = "public/pages/"
const file = `${folder}${page}.md`
const content = fs.readFileSync(file, "utf8")
const matterResult = matter(content)
return matterResult
} catch (e) {
notFound()
}
}

export async function generateStaticParams() {
Expand Down

0 comments on commit b98cc57

Please sign in to comment.