Add recemment modifié page accueil
This commit is contained in:
@ -335,6 +335,9 @@ func (h *Handler) generateHomeMarkdown() string {
|
||||
// Section des favoris (après les tags)
|
||||
h.generateFavoritesSection(&sb)
|
||||
|
||||
// Section des notes récemment modifiées (après les favoris)
|
||||
h.generateRecentNotesSection(&sb)
|
||||
|
||||
// Titre de l'arborescence avec le nombre de notes
|
||||
sb.WriteString(fmt.Sprintf("## 📂 Toutes les notes (%d)\n\n", noteCount))
|
||||
|
||||
@ -407,6 +410,56 @@ func (h *Handler) generateFavoritesSection(sb *strings.Builder) {
|
||||
sb.WriteString("</div>\n\n")
|
||||
}
|
||||
|
||||
// generateRecentNotesSection génère la section des notes récemment modifiées
|
||||
func (h *Handler) generateRecentNotesSection(sb *strings.Builder) {
|
||||
recentDocs := h.idx.GetRecentDocuments(5)
|
||||
|
||||
if len(recentDocs) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
sb.WriteString("## 🕒 Récemment modifiés\n\n")
|
||||
sb.WriteString("<div class=\"recent-notes-container\">\n")
|
||||
|
||||
for _, doc := range recentDocs {
|
||||
// Extraire les premières lignes du corps (max 150 caractères)
|
||||
preview := doc.Summary
|
||||
if len(preview) > 150 {
|
||||
preview = preview[:150] + "..."
|
||||
}
|
||||
|
||||
// Parser la date de modification pour un affichage plus lisible
|
||||
dateStr := doc.LastModified
|
||||
if dateStr == "" {
|
||||
dateStr = doc.Date
|
||||
}
|
||||
|
||||
sb.WriteString(" <div class=\"recent-note-card\">\n")
|
||||
sb.WriteString(fmt.Sprintf(" <a href=\"#\" class=\"recent-note-link\" hx-get=\"/api/notes/%s\" hx-target=\"#editor-container\" hx-swap=\"innerHTML\">\n", doc.Path))
|
||||
sb.WriteString(fmt.Sprintf(" <div class=\"recent-note-title\">%s</div>\n", doc.Title))
|
||||
sb.WriteString(fmt.Sprintf(" <div class=\"recent-note-meta\">\n"))
|
||||
sb.WriteString(fmt.Sprintf(" <span class=\"recent-note-date\">📅 %s</span>\n", dateStr))
|
||||
if len(doc.Tags) > 0 {
|
||||
sb.WriteString(fmt.Sprintf(" <span class=\"recent-note-tags\">"))
|
||||
for i, tag := range doc.Tags {
|
||||
if i > 0 {
|
||||
sb.WriteString(" ")
|
||||
}
|
||||
sb.WriteString(fmt.Sprintf("#%s", tag))
|
||||
}
|
||||
sb.WriteString("</span>\n")
|
||||
}
|
||||
sb.WriteString(" </div>\n")
|
||||
if preview != "" {
|
||||
sb.WriteString(fmt.Sprintf(" <div class=\"recent-note-preview\">%s</div>\n", preview))
|
||||
}
|
||||
sb.WriteString(" </a>\n")
|
||||
sb.WriteString(" </div>\n")
|
||||
}
|
||||
|
||||
sb.WriteString("</div>\n\n")
|
||||
}
|
||||
|
||||
// generateFavoriteFolderContent génère le contenu d'un dossier favori
|
||||
func (h *Handler) generateFavoriteFolderContent(sb *strings.Builder, folderPath string, depth int) {
|
||||
// Construire le chemin absolu
|
||||
|
||||
Reference in New Issue
Block a user