diff --git a/src/aggregator/index.ts b/src/aggregator/index.ts index 200db6f..41bd5cc 100644 --- a/src/aggregator/index.ts +++ b/src/aggregator/index.ts @@ -511,8 +511,17 @@ export class BacklogAggregator { tasks = tasks.filter((t) => (t.priority ?? "").toLowerCase() === priority.toLowerCase()); } - // Sort by project then by task ID + // Sort: due-date tasks first (soonest/overdue at top), then by project, then by task ID + const now = new Date().toISOString().slice(0, 10); tasks = tasks.sort((a, b) => { + const aDue = a.dueDate || ""; + const bDue = b.dueDate || ""; + // Tasks with due dates come before tasks without + if (aDue && !bDue) return -1; + if (!aDue && bDue) return 1; + // Both have due dates: sort soonest first + if (aDue && bDue) return aDue.localeCompare(bDue); + // Neither has due date: group by project, then by task ID const projectCompare = a.projectName.localeCompare(b.projectName); if (projectCompare !== 0) return projectCompare; return sortByTaskId([a, b])[0] === a ? -1 : 1; diff --git a/src/markdown/parser.ts b/src/markdown/parser.ts index 196128f..07a1b31 100644 --- a/src/markdown/parser.ts +++ b/src/markdown/parser.ts @@ -176,6 +176,13 @@ export function parseTask(content: string): Task { : frontmatter.estimatedHours !== undefined ? Number(frontmatter.estimatedHours) : undefined, + dueDate: frontmatter.due_date + ? normalizeDate(frontmatter.due_date) + : frontmatter.dueDate + ? normalizeDate(frontmatter.dueDate) + : frontmatter.deadline + ? normalizeDate(frontmatter.deadline) + : undefined, }; } diff --git a/src/types/index.ts b/src/types/index.ts index 50f51d4..9cd659c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -52,6 +52,8 @@ export interface Task { doToday?: boolean; /** Estimated hours to complete the task (for time tracking and invoicing) */ estimatedHours?: number; + /** Due date / deadline for the task (YYYY-MM-DD or YYYY-MM-DD HH:mm) */ + dueDate?: string; } /**