Skip to content

Commit

Permalink
Merge pull request #12 from bjarnef/patch-1
Browse files Browse the repository at this point in the history
Replace `XPath` queries
  • Loading branch information
Adolfi committed Nov 19, 2021
2 parents 7a69e86 + d439fae commit f9d644e
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Linq;
using System.Linq;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Web.Common;
using Umbraco.Extensions;
using UmbracoNineDemoSite.Core.Features.Shared.Constants;

namespace UmbracoNineDemoSite.Core.Features.Shared.Settings
Expand All @@ -14,8 +15,8 @@ public SiteSettings(UmbracoHelper umbracoHelper)
this.umbracoHelper = umbracoHelper;
}

private IPublishedContent home => this.umbracoHelper.ContentAtXPath($"//{ContentTypeAlias.Home}")?.FirstOrDefault();
private IPublishedContent settings => this.umbracoHelper.ContentAtXPath($"//{ContentTypeAlias.SiteSettings}")?.FirstOrDefault();
private IPublishedContent home => this.umbracoHelper.ContentAtRoot().FirstOrDefault(x => x.ContentType.Alias == ContentTypeAlias.Home);
private IPublishedContent settings => home?.FirstChild(x => x.ContentType.Alias == ContentTypeAlias.SiteSettings);

public string SiteName => this.home.Name;
public string CallToActionHeader => this.settings.GetProperty(PropertyAlias.CallToActionHeader).GetValue() as string;
Expand Down

0 comments on commit f9d644e

Please sign in to comment.