computer-scienceangular-roadmapbackend-roadmapblockchain-roadmapdba-roadmapdeveloper-roadmapdevops-roadmapfrontend-roadmapgo-roadmaphactoberfestjava-roadmapjavascript-roadmapnodejs-roadmappython-roadmapqa-roadmapreact-roadmaproadmapstudy-planvue-roadmapweb3-roadmap
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1005 B
42 lines
1005 B
3 years ago
|
import { NextApiRequest } from 'next';
|
||
|
import roadmaps from '../content/roadmaps.json';
|
||
|
|
||
|
export type RoadmapType = {
|
||
|
seo: {
|
||
|
title: string;
|
||
|
description: string;
|
||
|
keywords: string[]
|
||
|
},
|
||
|
title: string,
|
||
|
description: string,
|
||
|
featuredTitle: string;
|
||
|
featuredDescription: string,
|
||
|
author: {
|
||
|
name: string,
|
||
|
url: string
|
||
|
},
|
||
|
featured: boolean,
|
||
|
imagePath?: string,
|
||
|
contentPath?: string;
|
||
|
resourcesPath: string;
|
||
|
isCommunity: boolean;
|
||
|
url: string;
|
||
|
};
|
||
|
|
||
|
export function getRequestedRoadmap(req: NextApiRequest): RoadmapType | undefined {
|
||
|
// remove trailing slashes
|
||
|
const normalizedUrl = req.url?.replace(/\/$/, '') || '';
|
||
|
|
||
|
return (roadmaps as RoadmapType[]).find(roadmap => normalizedUrl.startsWith(roadmap.url));
|
||
|
}
|
||
|
|
||
|
export function getAllRoadmaps(): RoadmapType[] {
|
||
|
return (roadmaps as RoadmapType[]);
|
||
|
}
|
||
|
|
||
|
export function getFeaturedRoadmaps(): RoadmapType[] {
|
||
|
const roadmaps: RoadmapType[] = getAllRoadmaps();
|
||
|
|
||
|
return roadmaps.filter(roadmap => roadmap.featured);
|
||
|
}
|