mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-04-15 12:53:41 +02:00
Add 404 handling
This commit is contained in:
parent
a2e83e909e
commit
7f28a755dc
1
.astro/types.d.ts
vendored
1
.astro/types.d.ts
vendored
@ -1,2 +1 @@
|
||||
/// <reference types="astro/client" />
|
||||
/// <reference path="content.d.ts" />
|
@ -3,8 +3,6 @@ import Icon from '../components/AstroIcon.astro';
|
||||
import BaseLayout from '../layouts/BaseLayout.astro';
|
||||
import { getRoadmapIds } from '../lib/roadmap';
|
||||
|
||||
export const prerender = true;
|
||||
|
||||
const roadmapIds = await getRoadmapIds();
|
||||
const legacyRoadmapUrls = [...roadmapIds.map((id) => `/${id}/`), '/roadmaps/'];
|
||||
---
|
||||
|
@ -10,7 +10,10 @@ export const prerender = false;
|
||||
const { topicId, roadmapId } = Astro.params;
|
||||
|
||||
if (!topicId || !roadmapId) {
|
||||
return Astro.redirect('/404');
|
||||
Astro.response.status = 404;
|
||||
Astro.response.statusText = 'Not found';
|
||||
|
||||
return Astro.rewrite('/404');
|
||||
}
|
||||
|
||||
// Handle nested paths by joining the segments
|
||||
@ -48,7 +51,10 @@ if (!fs.existsSync(contentPath)) {
|
||||
);
|
||||
|
||||
if (!fs.existsSync(indexFilePath)) {
|
||||
return Astro.redirect('/404');
|
||||
Astro.response.status = 404;
|
||||
Astro.response.statusText = 'Not found';
|
||||
|
||||
return Astro.rewrite('/404');
|
||||
}
|
||||
|
||||
contentPath = indexFilePath;
|
||||
|
Loading…
x
Reference in New Issue
Block a user