Skip to content
Snippets Groups Projects
Verified Commit d54e99d4 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

fix: filesort

parent 792f1bd1
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,7 @@ package document
import (
"errors"
"fmt"
"os"
"path"
"path/filepath"
......@@ -40,13 +41,21 @@ func (m SourceFileMap) findByHash(hash string) *SourceFile {
func buildFileMap(files []*SourceFile) (SourceFileMap, []string) {
sort.Slice(files, func(i, j int) bool {
if files[i].level == files[j].level {
return files[i].relSourcePath < files[j].relSourcePath
if files[i].relSourcePath == files[j].relSourcePath {
if files[i].level < files[j].level {
return true
}
return files[i].level < files[j].level
}
return files[i].relSourcePath < files[j].relSourcePath
})
for _, f := range files {
fmt.Println(f.relSourcePath, f.level)
}
keys := make([]string, 0, len(files))
mapFiles := make(map[string]*SourceFile)
for _, file := range files {
......
......@@ -239,12 +239,11 @@ func buildTree(body string) *Tree[DocumentNode] {
if title, err := s.Html(); err == nil {
aID = slug.Make(title)
} else {
aID = "" + e.DataAtom.String() + "-" + randomID()
}
s.SetAttr("id", aID)
if aID == "" {
aID = "" + e.DataAtom.String() + "-" + randomID()
}
}
payload := DocumentNode{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment