site/docs improvements
This commit is contained in:
1 parent
26ddb94f5d
commit
e584c7aa63
8 files changed
+33
-11
No files matched your search
@@ -379,8 +379,9 @@ suspend fun initDocsDropdown() {
|
||||
val arr = JSON.parse(text) as Array<String>
|
||||
val all = arr.toList().sorted()
|
||||
dlog("docs-dd", "index entries=${all.size}")
|
||||
// Filter excluded by reading each markdown and looking for the marker
|
||||
// Filter excluded by reading each markdown and looking for the marker, and collect titles
|
||||
val filtered = mutableListOf<String>()
|
||||
val titles = mutableMapOf<String, String>()
|
||||
var excluded = 0
|
||||
var failed = 0
|
||||
for (path in all) {
|
||||
@@ -393,8 +394,12 @@ suspend fun initDocsDropdown() {
|
||||
continue
|
||||
}
|
||||
val body = r.text().await()
|
||||
if (!body.contains("[//]: # (excludeFromIndex)")) {
|
||||
if (!body.contains("[//]: # (excludeFromIndex)") &&
|
||||
body.contains("[//]: # (topMenu)") ) {
|
||||
filtered.add(path)
|
||||
// Reuse shared title extractor: first H1 or fallback to file name
|
||||
val title = extractTitleFromMarkdown(body) ?: path.substringAfterLast('/')
|
||||
titles[path] = title
|
||||
} else excluded++
|
||||
} catch (t: Throwable) {
|
||||
failed++
|
||||
@@ -404,10 +409,10 @@ suspend fun initDocsDropdown() {
|
||||
dlog("docs-dd", "filtered=${filtered.size} excluded=$excluded failed=$failed")
|
||||
// Sort entries by display name (file name) case-insensitively
|
||||
val sortedFiltered = filtered.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.substringAfterLast('/') })
|
||||
// Build items after the static first two existing children (tutorial + divider)
|
||||
// Build items after the static first items (tutorial, optional static entries, divider)
|
||||
var appended = 0
|
||||
sortedFiltered.forEach { path ->
|
||||
val name = path.substringAfterLast('/')
|
||||
val name = titles[path] ?: path.substringAfterLast('/')
|
||||
val li = document.createElement("li")
|
||||
val a = document.createElement("a") as HTMLAnchorElement
|
||||
a.className = "dropdown-item"
|
||||
|
||||
@@ -212,12 +212,14 @@
|
||||
</a>
|
||||
<ul id="docsDropdownMenu" class="dropdown-menu">
|
||||
<!-- Will be populated at runtime -->
|
||||
<li><a class="dropdown-item" href="#/docs/tutorial.md" data-route="docs">tutorial</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#/docs/tutorial.md" data-route="docs">Tutorial</a></li>
|
||||
<li><a class="dropdown-item" href="#/reference" data-route="reference">Reference</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#/reference" data-route="reference">Reference</a>
|
||||
<a class="nav-link" href="#/tryling" data-route="tryling">Try in browser</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
Reference in new issue
Block a user