-
+
+
+
-
+
}
@@ -64,7 +66,7 @@
private readonly IAsyncDebounce _debounce;
private SearchResult[]? _results;
- private ElementReference _input;
+ private ElementReference? _input;
private string? _searchQuery;
[Parameter] public bool IsOpen { get; set; }
@@ -111,6 +113,15 @@
public async Task OnAfterRenderAsync()
{
- await JSRuntime.InvokeVoidAsync("OnKeyUp", CancellationToken, _input, DotNetObjectReference.Create(this));
+ if (!_input.HasValue) return;
+
+ await JSRuntime.InvokeVoidAsync("OnKeyUp", CancellationToken, _input.Value, DotNetObjectReference.Create(this));
+ }
+
+ private void OnClick(SearchResult result)
+ {
+ IsOpenChanged.InvokeAsync(IsOpen = false);
+
+ Router.NavigateTo(result.Url);
}
}
\ No newline at end of file
diff --git a/website/Ignis.Website/Scripts/website.js b/website/Ignis.Website/Scripts/website.js
index d24035d..100aae8 100644
--- a/website/Ignis.Website/Scripts/website.js
+++ b/website/Ignis.Website/Scripts/website.js
@@ -16,6 +16,7 @@ window.OnPageLoad = () => {
}
window.OnKeyUp = (input, dotNetRef) => {
+ if (!input) return
input.onkeyup = (event) => {
dotNetRef.invokeMethodAsync('OnKeyUpAsync', event.key, input.value)
}
diff --git a/website/Ignis.Website/Services/SearchResult.cs b/website/Ignis.Website/Services/SearchResult.cs
index f1ab2b9..c8e5a00 100644
--- a/website/Ignis.Website/Services/SearchResult.cs
+++ b/website/Ignis.Website/Services/SearchResult.cs
@@ -14,7 +14,7 @@ public record SearchResult
public SearchResult(Page page, Section section)
{
Title = page.Title;
- Url = page.Link;
+ Url = $"/docs{page.Link}";
Section = section.Title;
}
diff --git a/website/Ignis.Website/Services/SearchService.cs b/website/Ignis.Website/Services/SearchService.cs
index f73655b..15bdbf0 100644
--- a/website/Ignis.Website/Services/SearchService.cs
+++ b/website/Ignis.Website/Services/SearchService.cs
@@ -69,7 +69,8 @@ public async IAsyncEnumerable
SearchAsync(string query,
{
foreach (var typeDocumentation in namespaceDocumentation.Types)
{
- if (typeDocumentation.Name.Contains(query, StringComparison.OrdinalIgnoreCase))
+ if (typeDocumentation.Name.Contains(query, StringComparison.OrdinalIgnoreCase)
+ || typeDocumentation.Namespace!.Contains(query, StringComparison.OrdinalIgnoreCase))
{
yield return new SearchResult(typeDocumentation);
}