New search function et drag and drop clean

This commit is contained in:
2025-11-10 19:40:14 +01:00
parent d969b05ead
commit cd9a96c760
42 changed files with 2164 additions and 34 deletions

View File

@ -638,3 +638,33 @@ func extractFrontMatter(path string) (frontMatter, error) {
fm, _, err := ExtractFrontMatterAndBody(path)
return frontMatter{Tags: fm.Tags}, err
}
// TagCount représente un tag avec son nombre d'utilisations
type TagCount struct {
Tag string
Count int
}
// GetAllTagsWithCount retourne tous les tags avec leur nombre d'utilisations, triés par popularité
func (i *Indexer) GetAllTagsWithCount() []TagCount {
i.mu.RLock()
defer i.mu.RUnlock()
result := make([]TagCount, 0, len(i.tags))
for tag, files := range i.tags {
result = append(result, TagCount{
Tag: tag,
Count: len(files),
})
}
// Trier par popularité (nombre décroissant), puis par nom alphabétique
sort.Slice(result, func(a, b int) bool {
if result[a].Count == result[b].Count {
return result[a].Tag < result[b].Tag
}
return result[a].Count > result[b].Count
})
return result
}