Pages corrections journal
This commit is contained in:
parent
786866ca30
commit
4de8eab879
@ -427,7 +427,26 @@ export default function CarnetPage() {
|
||||
// Frontend expects: { id, title, content, lastModified, type, mime, etag }
|
||||
const mappedNotes: Note[] = data.map((file: any) => {
|
||||
// Extract title from filename (remove .md extension if present)
|
||||
const title = file.name?.replace(/\.md$/, '') || file.name || 'Untitled';
|
||||
let title = file.name?.replace(/\.md$/, '') || file.name || 'Untitled';
|
||||
|
||||
// For Diary/Health folders, convert sanitized filename back to formatted title
|
||||
// Example: "16_janvier_2026" -> "16 janvier 2026"
|
||||
if ((folderLowercase === 'diary' || folderLowercase === 'health') && title.includes('_')) {
|
||||
// Check if it matches the date pattern: DD_mois_YYYY
|
||||
const datePattern = /^(\d{1,2})_([a-zéèêà]+)_(\d{4})$/i;
|
||||
const match = title.match(datePattern);
|
||||
if (match) {
|
||||
const day = match[1];
|
||||
const month = match[2];
|
||||
const year = match[3];
|
||||
// Capitalize first letter of month
|
||||
const monthCapitalized = month.charAt(0).toUpperCase() + month.slice(1);
|
||||
title = `${day} ${monthCapitalized} ${year}`;
|
||||
} else {
|
||||
// If pattern doesn't match, just replace underscores with spaces
|
||||
title = title.replace(/_/g, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
id: file.key || file.id || '',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user