add option to route root pages
This commit is contained in:
@@ -76,6 +76,7 @@
|
||||
public static class Pages
|
||||
{
|
||||
public const string FolderAlias = "zero.folder";
|
||||
public const string DefaultRootPageTypeAlias = "root";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user