* Revert "Revert "chore: update roadmap json endpoint"" This reverts commit8dbe1468ed. * Revert "Revert "feat: roadmap main page"" This reverts commitbb13bf38a8. * Revert "Revert "chore: replace roadmap listing"" This reverts commit80dfd5b206. * Revert "Revert "feat: roadmap courses"" This reverts commita89c2d454f. * Revert "Revert "fix: course length"" This reverts commitd1cf7cca99. * Revert "Revert "feat: roadmap with courses"" This reverts commit9c32f9d469. * Revert "Revert "chore: disable pre-render for roadmaps"" This reverts commitcef4c29f10.
92 lines
1.8 KiB
TypeScript
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;
|
|
}
|