Files
developer-roadmap/src/lib/roadmap.ts
T
Kamran Ahmed 2d18cefd55 Revert "Revert "feat: official roadmap meta"" (#9096)
* Revert "Revert "chore: update roadmap json endpoint""

This reverts commit 8dbe1468ed.

* Revert "Revert "feat: roadmap main page""

This reverts commit bb13bf38a8.

* Revert "Revert "chore: replace roadmap listing""

This reverts commit 80dfd5b206.

* Revert "Revert "feat: roadmap courses""

This reverts commit a89c2d454f.

* Revert "Revert "fix: course length""

This reverts commit d1cf7cca99.

* Revert "Revert "feat: roadmap with courses""

This reverts commit 9c32f9d469.

* Revert "Revert "chore: disable pre-render for roadmaps""

This reverts commit cef4c29f10.
2025-09-01 20:22:54 +01:00

92 lines
1.8 KiB
TypeScript

import type { PageType } from '../components/CommandMenu/CommandMenu';
import { httpGet } from './http';
import type { ResourceType } from './resource-progress';
export type AllowedRoadmapRenderer = 'balsamiq' | 'editor';
export interface RoadmapFrontmatter {
pdfUrl: string;
order: number;
briefTitle: string;
briefDescription: string;
title: string;
description: string;
hasTopics: boolean;
isForkable?: boolean;
isHidden: boolean;
isNew: boolean;
isUpcoming: boolean;
partner?: {
description: string;
link: string;
linkText: string;
};
courses?: {
title: string;
description: string;
link: string;
instructor: {
name: string;
image: string;
title: string;
};
features: string[];
}[];
note?: string;
question?: {
title: string;
description: string;
};
dimensions?: {
width: number;
height: number;
};
seo: {
title: string;
description: string;
ogImageUrl?: string;
keywords: string[];
};
schema?: {
headline: string;
description: string;
datePublished: string;
dateModified: string;
imageUrl: string;
};
relatedRoadmaps: string[];
relatedQuestions: string[];
sitemap: {
priority: number;
changefreq: string;
};
tags: string[];
renderer?: AllowedRoadmapRenderer;
}
export async function getResourceMeta(
resourceType: ResourceType,
resourceId: string,
) {
const { error, response } = await httpGet<PageType[]>(`/pages.json`);
if (error || !response) {
return null;
}
const page = response.find((page) => {
if (resourceType === 'roadmap') {
return page.url === `/${resourceId}`;
} else if (resourceType === 'best-practice') {
return page.url === `/best-practices/${resourceId}`;
}
return false;
});
if (!page) {
return null;
}
return page;
}