feat(Navigation) Added a search button for desktop users
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Text.RegularExpressions;
|
||||
using Model.Website;
|
||||
|
||||
namespace Model.Notes;
|
||||
|
||||
@@ -22,9 +24,42 @@ public class NoteContentModel
|
||||
|
||||
public string Description { get; set; }
|
||||
public string Content { get; set; }
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public virtual string LoadedContent { get; set; }
|
||||
|
||||
|
||||
public string IsHidden { get; set; } = "False";
|
||||
public string IsPreAlpha { get; set; } = "True";
|
||||
|
||||
public List<SearchPointModel> GetHeaders()
|
||||
{
|
||||
var regex = new Regex(@"^#* (.*)$", RegexOptions.Multiline);
|
||||
var listOfMatches = regex.Matches(LoadedContent);
|
||||
|
||||
Console.WriteLine($"Name: {Name}");
|
||||
|
||||
Console.WriteLine($"Matches: {listOfMatches.Count}");
|
||||
|
||||
List<SearchPointModel> foundHeaders = new List<SearchPointModel>();
|
||||
|
||||
foreach (var capture in listOfMatches)
|
||||
{
|
||||
var cleanUp = capture.ToString();
|
||||
cleanUp = cleanUp.ToLower();
|
||||
cleanUp = cleanUp.Replace("#", "");
|
||||
cleanUp = cleanUp.Replace("#", "");
|
||||
cleanUp = cleanUp.Replace("\"", "");
|
||||
cleanUp = cleanUp.Trim();
|
||||
cleanUp = cleanUp.Replace(" ", "-");
|
||||
foundHeaders.Add(new SearchPointModel(){ Title = capture.ToString().Trim(), Href = cleanUp});
|
||||
Console.WriteLine($"Capture: {cleanUp}");
|
||||
}
|
||||
|
||||
return foundHeaders;
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public virtual ICollection<NoteContentModel> NoteContentModels { get; set; } = new List<NoteContentModel>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user