fix: Add task numbers to mobile task index
- Extract task number from title (#XX pattern) or Task ID field - Display task number in gold before title - Clean up redundant 'Task #XX:' from displayed title - Sort by priority, then task number, then title Chronicler #69
This commit is contained in:
@@ -91,11 +91,27 @@ module.exports = async function() {
|
||||
|
||||
// Extract title from first H1
|
||||
const titleMatch = content.match(/^#\s+(.+)$/m);
|
||||
const title = titleMatch ? titleMatch[1] : dir.name;
|
||||
let title = titleMatch ? titleMatch[1] : dir.name;
|
||||
|
||||
// Extract task number from title (e.g., "Task #87:" or "# Task #87")
|
||||
let taskNumber = null;
|
||||
const taskNumMatch = title.match(/#(\d+)/);
|
||||
if (taskNumMatch) {
|
||||
taskNumber = taskNumMatch[1];
|
||||
} else {
|
||||
// Try to find task number in content
|
||||
const contentNumMatch = content.match(/\*\*Task ID:\*\*\s*#?(\d+)/i) ||
|
||||
content.match(/Task #(\d+)/i) ||
|
||||
content.match(/\*\*Task ID:\*\*\s*FFG-TASK-(\d+)/i);
|
||||
if (contentNumMatch) {
|
||||
taskNumber = contentNumMatch[1];
|
||||
}
|
||||
}
|
||||
|
||||
tasks.push({
|
||||
slug: dir.name,
|
||||
title: title,
|
||||
taskNumber: taskNumber,
|
||||
status: frontmatter.status || 'open',
|
||||
priority: frontmatter.priority || 'P3',
|
||||
owner: frontmatter.owner || 'Michael',
|
||||
@@ -109,11 +125,18 @@ module.exports = async function() {
|
||||
}
|
||||
}
|
||||
|
||||
// Sort by priority (P1 first) then by title
|
||||
// Sort by priority (P1 first) then by task number (if available) then by title
|
||||
tasks.sort((a, b) => {
|
||||
if (a.priority !== b.priority) {
|
||||
return a.priority.localeCompare(b.priority);
|
||||
}
|
||||
// Sort by task number if both have one
|
||||
if (a.taskNumber && b.taskNumber) {
|
||||
return parseInt(a.taskNumber) - parseInt(b.taskNumber);
|
||||
}
|
||||
// Tasks with numbers come before those without
|
||||
if (a.taskNumber && !b.taskNumber) return -1;
|
||||
if (!a.taskNumber && b.taskNumber) return 1;
|
||||
return a.title.localeCompare(b.title);
|
||||
});
|
||||
|
||||
@@ -122,7 +145,6 @@ module.exports = async function() {
|
||||
|
||||
} catch (err) {
|
||||
console.error('[11ty] Error fetching tasks:', err.message);
|
||||
// Return empty array - page will still build, just with no tasks
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user