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

fix: filesort

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