Add recemment modifié page accueil

This commit is contained in:
2025-11-12 17:44:02 +01:00
parent f903e28728
commit 6585b1765a
13 changed files with 218 additions and 60 deletions

View File

@ -710,6 +710,30 @@ func (i *Indexer) GetBacklinks(path string) []string {
return result
}
// GetRecentDocuments retourne les N documents les plus récemment modifiés
func (i *Indexer) GetRecentDocuments(limit int) []*Document {
i.mu.RLock()
defer i.mu.RUnlock()
// Copier tous les documents dans un slice
docs := make([]*Document, 0, len(i.docs))
for _, doc := range i.docs {
docs = append(docs, doc)
}
// Trier par date de dernière modification (décroissant)
sort.Slice(docs, func(i, j int) bool {
return docs[i].LastModified > docs[j].LastModified
})
// Limiter le nombre de résultats
if limit > 0 && len(docs) > limit {
docs = docs[:limit]
}
return docs
}
// extractInternalLinks extrait tous les liens internes d'un texte Markdown/HTML
// Format: <a ... hx-get="/api/notes/path/to/note.md" ...>
func extractInternalLinks(body string) []string {