Browse Source
Merge pull request #22065 from abpframework/docs-filter
Add "alternative words" to filter items in docs
pull/22112/head
oykuermann
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with
22 additions and
10 deletions
-
docs/en/docs-nav.json
-
modules/docs/src/Volo.Docs.Domain.Shared/Volo/Docs/Documents/NavigationNode.cs
-
modules/docs/src/Volo.Docs.Web/Areas/Documents/TagHelpers/TreeTagHelper.cs
-
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/index.js
|
|
|
@ -487,7 +487,8 @@ |
|
|
|
}, |
|
|
|
{ |
|
|
|
"text": "Exception Handling", |
|
|
|
"path": "framework/fundamentals/exception-handling.md" |
|
|
|
"path": "framework/fundamentals/exception-handling.md", |
|
|
|
"keywords": ["Error"] |
|
|
|
}, |
|
|
|
{ |
|
|
|
"text": "Localization", |
|
|
|
|
|
|
|
@ -21,6 +21,9 @@ namespace Volo.Docs.Documents |
|
|
|
|
|
|
|
[JsonPropertyName("isIndex")] |
|
|
|
public bool IsIndex { get; set; } |
|
|
|
|
|
|
|
[JsonPropertyName("keywords")] |
|
|
|
public string[] Keywords { get; set; } |
|
|
|
|
|
|
|
public bool IsLeaf => !HasChildItems; |
|
|
|
|
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using Microsoft.AspNetCore.Razor.TagHelpers; |
|
|
|
@ -23,7 +24,7 @@ namespace Volo.Docs.Areas.Documents.TagHelpers |
|
|
|
|
|
|
|
private const string LiItemTemplateWithLink = @"<li class='{0}'><span class='plus-icon'><i class='fa fa-{1}'></i></span>{2}{3}</li>"; |
|
|
|
|
|
|
|
private const string ListItemAnchor = @"<a href='{0}' class='{1}'>{2}</a>"; |
|
|
|
private const string ListItemAnchor = @"<a href='{0}' {1} class='{2}'>{3}</a>"; |
|
|
|
|
|
|
|
private const string ListItemSpan = @"<span class='{0}'>{1}</span>"; |
|
|
|
|
|
|
|
@ -155,7 +156,8 @@ namespace Volo.Docs.Areas.Documents.TagHelpers |
|
|
|
|
|
|
|
sb.Clear(); |
|
|
|
|
|
|
|
listInnerItem = string.Format(ListItemAnchor, NormalizePath(node.Path), textCss, |
|
|
|
var additionalAttributes = node.Keywords.IsNullOrEmpty() ? "" : "data-keywords=\"" + node.Keywords.JoinAsString(",") + "\""; |
|
|
|
listInnerItem = string.Format(ListItemAnchor, NormalizePath(node.Path), additionalAttributes ,textCss, |
|
|
|
node.Text.IsNullOrEmpty() |
|
|
|
? "?" |
|
|
|
: sb.Append(node.Text).Append(badgeStringBuilder.ToString()).ToString()); |
|
|
|
|
|
|
|
@ -29,7 +29,8 @@ var doc = doc || {}; |
|
|
|
var $ul = $(`<ul class="nav nav-list tree" ${uiCss}></ul>`); |
|
|
|
var $li = $(`<li class="${node.hasChildItems ? 'nav-header' : 'last-link'}"></li>`); |
|
|
|
|
|
|
|
$li.append(`<span class="plus-icon"> <i class="fa fa-${node.hasChildItems ? 'chevron-right' : node.path === "javascript:;" ? 'has-link' : 'no-link'}"></i></span><a href="${node.path}" class="${textCss}">${node.text}</a>`) |
|
|
|
var dataKeywords = node.keywords ? `data-keywords="${node.keywords}"` : ""; |
|
|
|
$li.append(`<span class="plus-icon"> <i class="fa fa-${node.hasChildItems ? 'chevron-right' : node.path === "javascript:;" ? 'has-link' : 'no-link'}"></i></span><a href="${node.path}" ${dataKeywords} class="${textCss}">${node.text}</a>`) |
|
|
|
|
|
|
|
if(node.isLazyExpandable){ |
|
|
|
$li.addClass("lazy-expand"); |
|
|
|
@ -111,12 +112,17 @@ var doc = doc || {}; |
|
|
|
var filteredItems = $navigation |
|
|
|
.find('li > a') |
|
|
|
.filter(function () { |
|
|
|
return ( |
|
|
|
$(this) |
|
|
|
.text() |
|
|
|
.toUpperCase() |
|
|
|
.indexOf(filterText.toUpperCase()) > -1 |
|
|
|
); |
|
|
|
var keywords = ($(this).data('keywords') || "").split(","); |
|
|
|
var text = $(this).text(); |
|
|
|
|
|
|
|
if(text.toUpperCase().indexOf(filterText.toUpperCase()) > -1) |
|
|
|
{ |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
return keywords.some(function(keyword){ |
|
|
|
return keyword.toUpperCase().indexOf(filterText.toUpperCase()) > -1; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
filteredItems.each(function () { |
|
|
|
|