Omit Files section when no files are present
This commit is contained in:
@@ -232,6 +232,13 @@ func listEntries(fsPath, urlPath, sortKey, order string) []entry {
|
|||||||
sortEntries(folders, sortName, order)
|
sortEntries(folders, sortName, order)
|
||||||
sortEntries(files, sortKey, order)
|
sortEntries(files, sortKey, order)
|
||||||
|
|
||||||
|
// Nothing to list (only index.md, which is rendered above): return no
|
||||||
|
// entries so the Files section is suppressed entirely rather than showing
|
||||||
|
// an empty listing with just the `..` row.
|
||||||
|
if len(folders) == 0 && len(files) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// `..` row mirrors the header Up button so the listing itself is
|
// `..` row mirrors the header Up button so the listing itself is
|
||||||
// navigable without reaching for the header on mobile. Prepended after
|
// navigable without reaching for the header on mobile. Prepended after
|
||||||
// sort so it always sits at the top regardless of folder names.
|
// sort so it always sits at the top regardless of folder names.
|
||||||
|
|||||||
Reference in New Issue
Block a user