parent
2cfcbf9a51
commit
9355c1e770
10 changed files with 283 additions and 68 deletions
@ -1,19 +1,38 @@ |
||||
import { Badge } from '../Badge.tsx'; |
||||
import type { |
||||
ProjectDifficultyType, |
||||
ProjectFileType, |
||||
} from '../../lib/project.ts'; |
||||
|
||||
type ProjectCardProps = { |
||||
project: ProjectFileType; |
||||
}; |
||||
|
||||
const badgeVariants: Record<ProjectDifficultyType, string> = { |
||||
beginner: 'yellow', |
||||
intermediate: 'green', |
||||
advanced: 'red', |
||||
}; |
||||
|
||||
export function ProjectCard(props: ProjectCardProps) { |
||||
const { project } = props; |
||||
|
||||
const { frontmatter, id } = project; |
||||
|
||||
export function ProjectCard() { |
||||
return ( |
||||
<a |
||||
href="#" |
||||
href={`/projects/${id}`} |
||||
className="flex flex-col rounded-md border bg-white p-3 transition-colors hover:border-gray-300 hover:bg-gray-50" |
||||
> |
||||
<span className="flex justify-between gap-1.5"> |
||||
<Badge variant={'yellow'} text={'Beginner'} /> |
||||
<Badge variant={'grey'} text={'API'} /> |
||||
</span> |
||||
<span className="mb-1 mt-2.5 font-medium">Bank Application</span> |
||||
<span className="text-sm text-gray-500"> |
||||
Create a simple CLI to collect and calculate the taxes. |
||||
<Badge |
||||
variant={badgeVariants[frontmatter.difficulty] as any} |
||||
text={frontmatter.difficulty} |
||||
/> |
||||
<Badge variant={'grey'} text={frontmatter.nature} /> |
||||
</span> |
||||
<span className="mb-1 mt-2.5 font-medium">{frontmatter.title}</span> |
||||
<span className="text-sm text-gray-500">{frontmatter.description}</span> |
||||
</a> |
||||
); |
||||
} |
||||
|
@ -0,0 +1,36 @@ |
||||
--- |
||||
title: 'Stock CLI' |
||||
description: 'Build a command line interface (CLI) to track your tasks and manage your to-do list.' |
||||
isNew: false |
||||
difficulty: 'intermediate' |
||||
nature: 'API' |
||||
skills: |
||||
- 'Programming Language' |
||||
- 'CLI' |
||||
- 'Filesystem' |
||||
- 'Logic Building' |
||||
seo: |
||||
title: 'Task Tracker CLI' |
||||
description: 'Build a command line interface (CLI) to track your tasks and manage your to-do list.' |
||||
keywords: |
||||
- 'task tracker cli' |
||||
- 'backend project idea' |
||||
roadmapIds: |
||||
- 'backend' |
||||
--- |
||||
|
||||
# Task Tracker CLI |
||||
|
||||
Build a command line interface (CLI) to track your tasks and manage your to-do list. |
||||
|
||||
## Description |
||||
|
||||
You are required to build a command line interface (CLI) application that allows users to manage their tasks and to-do list. The application should be able to perform the following operations: |
||||
|
||||
- Add a new task |
||||
- List all tasks |
||||
- Mark a task as done |
||||
- Delete a task |
||||
- Update a task |
||||
- Search for a task |
||||
- Filter tasks by status (done, pending) |
@ -0,0 +1,36 @@ |
||||
--- |
||||
title: 'Task Tracker CLI' |
||||
description: 'Build a command line interface (CLI) to track your tasks and manage your to-do list.' |
||||
isNew: false |
||||
difficulty: 'beginner' |
||||
nature: 'API' |
||||
skills: |
||||
- 'Programming Language' |
||||
- 'CLI' |
||||
- 'Filesystem' |
||||
- 'Logic Building' |
||||
seo: |
||||
title: 'Task Tracker CLI' |
||||
description: 'Build a command line interface (CLI) to track your tasks and manage your to-do list.' |
||||
keywords: |
||||
- 'task tracker cli' |
||||
- 'backend project idea' |
||||
roadmapIds: |
||||
- 'backend' |
||||
--- |
||||
|
||||
# Task Tracker CLI |
||||
|
||||
Build a command line interface (CLI) to track your tasks and manage your to-do list. |
||||
|
||||
## Description |
||||
|
||||
You are required to build a command line interface (CLI) application that allows users to manage their tasks and to-do list. The application should be able to perform the following operations: |
||||
|
||||
- Add a new task |
||||
- List all tasks |
||||
- Mark a task as done |
||||
- Delete a task |
||||
- Update a task |
||||
- Search for a task |
||||
- Filter tasks by status (done, pending) |
@ -0,0 +1,82 @@ |
||||
import type { MarkdownFileType } from './file'; |
||||
|
||||
export const projectDifficulties = ['beginner', 'intermediate', 'advanced'] as const; |
||||
export type ProjectDifficultyType = (typeof projectDifficulties)[number]; |
||||
|
||||
export interface ProjectFrontmatter { |
||||
title: string; |
||||
description: string; |
||||
isNew: boolean; |
||||
difficulty: ProjectDifficultyType; |
||||
nature: string; |
||||
skills: string[]; |
||||
seo: { |
||||
title: string; |
||||
description: string; |
||||
keywords: string[]; |
||||
}; |
||||
roadmapIds: string[]; |
||||
} |
||||
|
||||
export type ProjectFileType = MarkdownFileType<ProjectFrontmatter> & { |
||||
id: string; |
||||
}; |
||||
|
||||
/** |
||||
* Generates id from the given project file |
||||
* @param filePath Markdown file path |
||||
* |
||||
* @returns unique project identifier |
||||
*/ |
||||
function projectPathToId(filePath: string): string { |
||||
const fileName = filePath.split('/').pop() || ''; |
||||
|
||||
return fileName.replace('.md', ''); |
||||
} |
||||
|
||||
export async function getProjectsByRoadmapId( |
||||
roadmapId: string, |
||||
): Promise<ProjectFileType[]> { |
||||
const projects = await getAllProjects(); |
||||
|
||||
return projects.filter((project) => |
||||
project.frontmatter?.roadmapIds?.includes(roadmapId), |
||||
); |
||||
} |
||||
|
||||
let tempProjects: ProjectFileType[] = []; |
||||
|
||||
/** |
||||
* Gets all the projects sorted by the publishing date |
||||
* @returns Promisifed project files |
||||
*/ |
||||
export async function getAllProjects(): Promise<ProjectFileType[]> { |
||||
if (tempProjects.length) { |
||||
return tempProjects; |
||||
} |
||||
|
||||
const projects = import.meta.glob<ProjectFileType>( |
||||
'/src/data/projects/*.md', |
||||
{ |
||||
eager: true, |
||||
}, |
||||
); |
||||
|
||||
tempProjects = Object.values(projects).map((projectFile) => ({ |
||||
...projectFile, |
||||
id: projectPathToId(projectFile.file), |
||||
})); |
||||
|
||||
return tempProjects; |
||||
} |
||||
|
||||
export async function getProjectById( |
||||
groupId: string, |
||||
): Promise<ProjectFileType> { |
||||
const project = await import(`../data/projects/${groupId}.md`); |
||||
|
||||
return { |
||||
...project, |
||||
id: projectPathToId(project.file), |
||||
}; |
||||
} |
Loading…
Reference in new issue