add option to route root pages

This commit is contained in:
2021-01-19 13:07:38 +01:00
parent 05854e6dcf
commit a6114fd3b1
3 changed files with 12 additions and 1 deletions
+1
View File
@@ -76,6 +76,7 @@
public static class Pages
{
public const string FolderAlias = "zero.folder";
public const string DefaultRootPageTypeAlias = "root";
}
}
}
+2
View File
@@ -11,6 +11,8 @@ namespace zero.Core.Options
}
public string Root { get; set; } = Constants.Pages.DefaultRootPageTypeAlias;
public void Add<T>(PageType<T> pageType) where T : Page, new()
{
+9 -1
View File
@@ -10,6 +10,7 @@ using zero.Core.Database;
using zero.Core.Database.Indexes;
using zero.Core.Entities;
using zero.Core.Extensions;
using zero.Core.Options;
namespace zero.Core.Routing
{
@@ -21,10 +22,13 @@ namespace zero.Core.Routing
protected IZeroStore Store { get; private set; }
protected IZeroOptions Options { get; private set; }
public PageUrlBuilder(IZeroStore store)
public PageUrlBuilder(IZeroStore store, IZeroOptions options)
{
Store = store;
Options = options;
}
@@ -115,6 +119,10 @@ namespace zero.Core.Routing
{
alias = page.UrlAlias;
}
else if (page.PageTypeAlias == Options.Pages.Root)
{
return String.Empty;
}
else if (!page.Alias.IsNullOrWhiteSpace())
{
alias = page.Alias;