public XMLSitemapItemViewModel(ISeo page) { Url = page.Url(mode: UrlMode.Absolute); ChangeDate = page.UpdateDate.ToUniversalTime(); ChangeFrequency = page.SitemapChangeFrequency; Priority = page.SitemapPriority; }
/// <summary> /// Returns canonical url. /// </summary> /// <param name="seo">The seo.</param> /// <param name="canonicalDomain">The canonical domain.</param> /// <returns></returns> public static string GetCanonicalUrl(this ISeo seo, string canonicalDomain) { if (seo.CanonicalLink != null) { return(seo.CanonicalLink.Url); } if (canonicalDomain.IsNullOrWhiteSpace()) { return(seo.Url(mode: UrlMode.Absolute)); } try { return($"{new Uri(seo.Url(mode: UrlMode.Absolute)).Scheme}://{canonicalDomain}{seo.Url}"); } catch (Exception) { //ignore //this check is because of the preview option in the CMS } return(string.Empty); }