Closed chronark closed 8 months ago
hey @chronark, I am able to solve the issue by making some changes in raw function in the mdx-helper.tsx. I have add to try and catch block so whenever there no filepath for slug then it redirects to blog
`export const raw = async ({contentPath,filepath,}: {contentPath: string;filepath: string;}) => {`try {
const fileContent = await fs.readFile(`${contentPath}/${filepath}.mdx`, "utf-8");
return fileContent } catch(error){
redirect(`/blog`)}};`
https://github.com/unkeyed/unkey/assets/100031493/f3ca524b-8e0a-4f93-ba3f-4e9f7d2eb12c
lgtm cc @perkinsjr
It should probably 404 and not redirect back to the blog. The rest is the correct approach.
@perkinsjr ok I can make changes and submit a Pull request ?
Yup
Preliminary Checks
Reproduction / Replay Link (Optional)
No response
Issue Summary
/blog/\\\\\\\[slug\\\\\\\] pages throw a 500 error when the blog does not exist
Steps to Reproduce
Go to https://unkey.dev/blog/xxx
Expected behavior
It should redirect to /blog
Other information
Solution idea: Catch the
fs.readFile
error and redirectScreenshots
No response
Version info