Skip to content

Commit 94188af

Browse files
committed
fix sorting across extensions
1 parent ad08478 commit 94188af

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

html-generators/generate.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,21 @@ SequencedMap<String, Snippet> loadAllSnippets() throws IOException {
135135
for (var cat : CATEGORY_DISPLAY.sequencedKeySet()) {
136136
var catDir = Path.of(CONTENT_DIR, cat);
137137
if (!Files.isDirectory(catDir)) continue;
138+
var sorted = new ArrayList<Path>();
139+
// first collect and sortall files
138140
for (var ext : MAPPERS.keySet()) {
139141
try (var stream = Files.newDirectoryStream(catDir, "*." + ext)) {
140-
var sorted = new ArrayList<Path>();
141142
stream.forEach(sorted::add);
142-
sorted.sort(Path::compareTo);
143-
for (var path : sorted) {
144-
var snippet = new Snippet(MAPPERS.get(ext).readTree(path.toFile()));
145-
snippets.put(snippet.key(), snippet);
146-
}
147143
}
148144
}
145+
sorted.sort(Path::compareTo);
146+
for (var path : sorted) {
147+
var filename = path.getFileName().toString();
148+
var ext = filename.substring(filename.lastIndexOf('.') + 1);
149+
var json = MAPPERS.get(ext).readTree(path.toFile());
150+
var snippet = new Snippet(json);
151+
snippets.put(snippet.key(), snippet);
152+
}
149153
}
150154
return snippets;
151155
}

0 commit comments

Comments
 (0)