feat: definir contratos do notebook story
This commit is contained in:
1 parent
d89dde21ee
commit
8b858528f8
4 files changed
+337
No files matched your search
@@ -0,0 +1,52 @@
|
||||
import type { PortfolioProject } from "@/lib/portfolio-data";
|
||||
|
||||
export type NotebookProject = {
|
||||
id: string;
|
||||
title: string;
|
||||
subtitle: string;
|
||||
demoUrl: string;
|
||||
technologies: string[];
|
||||
screenshotSrc: string;
|
||||
};
|
||||
|
||||
const NOTEBOOK_ORDER = [
|
||||
"nutriscan",
|
||||
"sc-plus",
|
||||
"sev-modaintima",
|
||||
"as-servicos",
|
||||
] as const;
|
||||
|
||||
const SCREENSHOT_BY_PROJECT_ID: Record<(typeof NOTEBOOK_ORDER)[number], string> = {
|
||||
nutriscan: "/assets/prints/print-nutriscan.png",
|
||||
"sc-plus": "/assets/prints/print-scplus.png",
|
||||
"sev-modaintima": "/assets/prints/print-sev.png",
|
||||
"as-servicos": "/assets/prints/print-asservicos.png",
|
||||
};
|
||||
|
||||
function isApprovedDemoUrl(value: PortfolioProject["demoUrl"]): value is string {
|
||||
return typeof value === "string" && /^https?:\/\//.test(value);
|
||||
}
|
||||
|
||||
export function selectNotebookProjects(
|
||||
projects: readonly PortfolioProject[],
|
||||
): NotebookProject[] {
|
||||
return NOTEBOOK_ORDER.flatMap((id) => {
|
||||
const project = projects.find((candidate) => candidate.id === id);
|
||||
const screenshotSrc = SCREENSHOT_BY_PROJECT_ID[id];
|
||||
|
||||
if (!project || !isApprovedDemoUrl(project.demoUrl)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
id: project.id,
|
||||
title: project.title,
|
||||
subtitle: project.subtitle,
|
||||
demoUrl: project.demoUrl,
|
||||
technologies: [...project.technologies],
|
||||
screenshotSrc,
|
||||
},
|
||||
];
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user