コード例 #1
0
 public XMLSitemapItemViewModel(ISeo page)
 {
     Url             = page.Url(mode: UrlMode.Absolute);
     ChangeDate      = page.UpdateDate.ToUniversalTime();
     ChangeFrequency = page.SitemapChangeFrequency;
     Priority        = page.SitemapPriority;
 }
コード例 #2
0
        /// <summary>
        /// Returns formatted <paramref name="seo"/> SEO title, based on specified <paramref name="format"/>.
        /// </summary>
        /// <param name="seo">The seo.</param>
        /// <param name="currentPage">The current page.</param>
        /// <param name="brandName">Brand name to use in the SEO title.</param>
        /// <param name="format">Format to use. First placeholder is used for SEO title, and second one for brand name.</param>
        /// <param name="discardTitleForHomePage">If <c>true</c> only brand name will be used for Home Page SEO title.</param>
        /// <returns>Formatted <paramref name="seo"/> SEO title.</returns>
        public static string GetFormattedSeoTitle(this ISeo seo, IPage currentPage, string brandName, string format = "{0} | {1}", bool discardTitleForHomePage = true)
        {
            if (discardTitleForHomePage && currentPage.IsHome())
            {
                return(brandName);
            }

            string seoTitle = seo.SeoTitle.IsNullOrWhiteSpace() ? currentPage.PageTitle() : seo.SeoTitle;

            return(brandName.IsNullOrWhiteSpace() ? seoTitle : string.Format(format, seoTitle, brandName));
        }
コード例 #3
0
        private SeoManager()
        {
            switch (_seoProvider.ToLower())
            {
            case "lucenenet":
                iSeo = new LuceneNetSeo(indexPath);
                break;

            default:
                throw new ArgumentException("搜索引擎只支持lucenenet");
            }
        }
コード例 #4
0
        public OpenGraphViewModel(IPageContext <IPage> context, ISeo seo)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (seo == null)
            {
                throw new ArgumentNullException(nameof(seo));
            }

            Title       = GetTitle(context.Page);
            Description = GetDescription(context.Page);
            //TODO if Open Graph Image is null use banner image
            Image        = context.Page.OpenGraphImage.ToViewModel();
            CanonicalUrl = seo.GetCanonicalUrl(context.SiteSettings.CanonicalDomain);
            Locale       = context.Page.GetCultureFromDomains();
            SiteName     = context.SiteSettings.SiteName;
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
 /// <summary>Static getter for Meta description</summary>
 public static string GetMetaDescription(ISeo that)
 {
     return(that.GetPropertyValue <string>("metaDescription"));
 }
コード例 #7
0
 /// <summary>Static getter for Page Title</summary>
 public static string GetPageTitle(ISeo that)
 {
     return(that.GetPropertyValue <string>("pageTitle"));
 }
コード例 #8
0
 /// <summary>Static getter for Open Graph image</summary>
 public static string GetOgImage(ISeo that)
 {
     return(that.GetPropertyValue <string>("ogImage"));
 }
 public static global::Umbraco.Web.Models.Link GetCanonicalUrl(ISeo that) => that.Value <global::Umbraco.Web.Models.Link>("canonicalURL");
 public static global::System.Collections.Generic.IEnumerable <string> GetTags(ISeo that) => that.Value <global::System.Collections.Generic.IEnumerable <string> >("tags");
 public static string GetPagetitle(ISeo that) => that.Value <string>("pagetitle");
 public static global::Umbraco.Core.Models.PublishedContent.IPublishedContent GetImage(ISeo that) => that.Value <global::Umbraco.Core.Models.PublishedContent.IPublishedContent>("image");
 public static string GetDescription(ISeo that) => that.Value <string>("description");
コード例 #14
0
 /// <summary>Static getter for Meta title</summary>
 public static string GetMetaTitle(ISeo that)
 {
     return(that.GetPropertyValue <string>("metaTitle"));
 }
コード例 #15
0
 /// <summary>Static getter for No index</summary>
 public static bool GetNoIndex(ISeo that)
 {
     return(that.GetPropertyValue <bool>("noIndex"));
 }
コード例 #16
0
 public static XMLSitemapItemViewModel ToViewModel(this ISeo page)
 => page != null ? new XMLSitemapItemViewModel(page) : default(XMLSitemapItemViewModel);