Roadmap to becoming a developer in 2022
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.

139 lines
3.1 KiB

import type { MarkdownFileType } from './file';
export interface RoadmapFrontmatter {
2 years ago
pdfUrl: string;
order: number;
briefTitle: string;
briefDescription: string;
2 years ago
title: string;
description: string;
hasTopics: boolean;
isForkable?: boolean;
isHidden: boolean;
isNew: boolean;
isUpcoming: boolean;
tnsBannerLink?: string;
note?: string;
question?: {
title: string;
description: string;
};
dimensions?: {
2 years ago
width: number;
height: number;
};
seo: {
title: string;
description: string;
2 years ago
ogImageUrl?: string;
2 years ago
keywords: string[];
};
schema?: {
headline: string;
description: string;
datePublished: string;
dateModified: string;
imageUrl: string;
};
2 years ago
relatedRoadmaps: string[];
relatedQuestions: string[];
2 years ago
sitemap: {
priority: number;
changefreq: string;
};
tags: string[];
}
export type RoadmapFileType = MarkdownFileType<RoadmapFrontmatter> & {
id: string;
};
function roadmapPathToId(filePath: string): string {
const fileName = filePath.split('/').pop() || '';
return fileName.replace('.md', '');
}
/**
* Gets the IDs of all the roadmaps available on the website
*
* @returns string[] Array of roadmap IDs
*/
export async function getRoadmapIds() {
12 months ago
const roadmapFiles = import.meta.glob<RoadmapFileType>(
2 years ago
'/src/data/roadmaps/*/*.md',
{
eager: true,
},
2 years ago
);
2 years ago
return Object.keys(roadmapFiles).map(roadmapPathToId);
}
/**
* Gets the roadmap files which have the given tag assigned
*
* @param tag Tag assigned to roadmap
* @returns Promisified RoadmapFileType[]
*/
2 years ago
export async function getRoadmapsByTag(
tag: string,
2 years ago
): Promise<RoadmapFileType[]> {
12 months ago
const roadmapFilesMap = import.meta.glob<RoadmapFileType>(
2 years ago
'/src/data/roadmaps/*/*.md',
{
eager: true,
},
2 years ago
);
12 months ago
const roadmapFiles: RoadmapFileType[] = Object.values(roadmapFilesMap);
const filteredRoadmaps = roadmapFiles
.filter((roadmapFile) => roadmapFile.frontmatter.tags.includes(tag))
.map((roadmapFile) => ({
...roadmapFile,
id: roadmapPathToId(roadmapFile.file),
}));
2 years ago
return filteredRoadmaps.sort(
(a, b) => a.frontmatter.order - b.frontmatter.order,
2 years ago
);
}
export async function getRoadmapById(id: string): Promise<RoadmapFileType> {
12 months ago
const roadmapFilesMap: Record<string, RoadmapFileType> =
import.meta.glob<RoadmapFileType>('/src/data/roadmaps/*/*.md', {
2 years ago
eager: true,
12 months ago
});
const roadmapFile = Object.values(roadmapFilesMap).find((roadmapFile) => {
return roadmapPathToId(roadmapFile.file) === id;
});
if (!roadmapFile) {
throw new Error(`Roadmap with ID ${id} not found`);
}
return {
...roadmapFile,
id: roadmapPathToId(roadmapFile.file),
};
}
2 years ago
export async function getRoadmapsByIds(
ids: string[],
2 years ago
): Promise<RoadmapFileType[]> {
if (!ids?.length) {
return [];
}
return Promise.all(ids.map((id) => getRoadmapById(id)));
}
feat: profile pages, custom roadmap pages and SSR (#5494) * Update * Add stats and health endpoints * Add pre-render * fix: redirect to the error page * Fix generate-renderer issue * Rename * Fix best practice topics not loading * Handle SSR for static pages * Refactor faqs * Refactor best practices * Fix absolute import * Fix stats * Add custom roadmap page * Minor UI change * feat: custom roadmap slug routes (#4987) * feat: replace roadmap slug * fix: remove roadmap slug * feat: username route * fix: user public page * feat: show roadmap progress * feat: update public profile * fix: replace with toast * feat: user public profile page * feat: implement profile form * feat: implement user profile roadmap page * refactor: remove logs * fix: increase progress gap * fix: remove title margin * fix: breakpoint for roadmaps * Update dependencies * Upgrade dependencies * fix: improper avatars * fix: heatmap focus * wip: remove `getStaticPaths` * fix: add disable props * wip * feat: add email icon * fix: update pnpm lock * fix: implement author page * Fix beginner roadmaps not working * Changes to form * Refactor profile and form * Refactor public profile form * Rearrange sidebar items * Update UI for public form * Minor text update * Refactor public profile form * Error page for user * Revamp UI for profile page * Add public profile page * Fix vite warnings * Add private profile banner * feat: on blur check username * Update fetch depth * Add error detail * Use hybrid mode of rendering * Do not pre-render stats pages * Update deployment workflow * Update deployment workflow --------- Co-authored-by: Arik Chakma <arikchangma@gmail.com>
10 months ago
export async function getRoadmapFaqsById(roadmapId: string): Promise<string[]> {
const { faqs } = await import(
`../data/roadmaps/${roadmapId}/faqs.astro`
).catch(() => ({}));
return faqs || [];
}