ssg: StaticSitePage, StaticSiteClient: ResolveParent impl, resolve page parent on GetPage
This commit is contained in:
parent
923acc40ad
commit
9ee13c5a59
|
@ -224,8 +224,12 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
|
|||
|
||||
}
|
||||
|
||||
public BlogPost GetPage(string blogId, string pageId) =>
|
||||
StaticSitePage.GetPageById(Config, pageId).BlogPost;
|
||||
public BlogPost GetPage(string blogId, string pageId)
|
||||
{
|
||||
var page = StaticSitePage.GetPageById(Config, pageId);
|
||||
page.ResolveParent();
|
||||
return page.BlogPost;
|
||||
}
|
||||
|
||||
public PageInfo[] GetPageList(string blogId) =>
|
||||
StaticSitePage.GetAllPages(Config).Select(page => page.PageInfo).ToArray();
|
||||
|
|
|
@ -84,6 +84,27 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
|
|||
GetFileNameForProvidedSlug(slug));
|
||||
}
|
||||
|
||||
public StaticSitePage ResolveParent()
|
||||
{
|
||||
if(!BlogPost.PageParent.IsEmpty)
|
||||
{
|
||||
// Attempt to locate and load parent
|
||||
var parent = GetPageById(SiteConfig, BlogPost.PageParent.Id);
|
||||
if (parent == null)
|
||||
{
|
||||
// Parent not found, set PageParent to empty
|
||||
BlogPost.PageParent = PostIdAndNameField.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Populate Name field
|
||||
BlogPost.PageParent = new PostIdAndNameField(parent.Id, parent.BlogPost.Title);
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load published page from a specified file path
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue