Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new meta data object from the specified <paramref name="site"/> and <paramref name="content"/>.
        /// </summary>
        /// <param name="site">A reference to the current site.</param>
        /// <param name="content">A reference the content item representing the current page.</param>
        public SpaMetaData(SpaSiteModel site, IPublishedContent content)
        {
            string seoTitle           = content.GetString(Constants.SkyConstants.Properties.SeoTitle);
            string seoMetaDescription = content.GetString(Constants.SkyConstants.Properties.SeoMetaDescription);

            string contentName       = content.Name;
            string contentTitleText  = content.GetSpaTitle().Replace("&shy;", "").Replace("<br />", "");
            string contentTeaserText = StringUtils.StripHtml(content.GetString(Constants.SkyConstants.Properties.Teaser) ?? "");

            MetaTitle       = GetString(seoTitle, contentTitleText, contentName) + " - " + site.Name;
            MetaDescription = GetString(seoMetaDescription, contentTeaserText);

            // Should the page be hidden from search engines?
            if (HttpContext.Current.Request.Url.Host.Contains(SkyConstants.SolutionId + "."))
            {
                HideFromSearch = true;
                Robots         = "noindex, nofollow";
            }
            else if (content.GetBoolean("hideFromSearch"))
            {
                HideFromSearch = true;
                Robots         = "noindex, follow";
            }
            else
            {
                Robots = "index, follow";
            }

            string siteUrl = site.Content.GetSpaUrlWithDomain();

            string   ogTitle       = content.GetString(SkyConstants.Properties.OpenGraphTitle);
            string   ogDescription = content.GetString(SkyConstants.Properties.OpenGraphDescription);
            SpaImage ogImage       = content.TypedMedia(SkyConstants.Properties.OpenGraphImage, SpaImage.GetFromContent) ?? content.TypedMedia(Constants.SkyConstants.Properties.Image, SpaImage.GetFromContent);

            OpenGraphTitle       = GetString(ogTitle, contentTitleText, contentName);
            OpenGraphDescription = GetString(ogDescription, seoMetaDescription, contentTeaserText);
            OpenGraphSiteName    = site.Name;
            OpenGraphUrl         = content.GetSpaUrl();

            OpenGraphImages = new List <SpaOpenGraphImage>();

            if (ogImage != null)
            {
                if (ogImage.Width >= 1200 && ogImage.Height >= 630)
                {
                    string cropUrl = siteUrl + ogImage.GetCropUrl(1200, 630).TrimStart('/');
                    OpenGraphImages.Add(new SpaOpenGraphImage(cropUrl, 1200, 630));
                }
                else if (ogImage.Width >= 600 && ogImage.Height >= 315)
                {
                    string cropUrl = siteUrl + ogImage.GetCropUrl(600, 315);
                    OpenGraphImages.Add(new SpaOpenGraphImage(cropUrl, 600, 315));
                }
            }
        }
Exemplo n.º 2
0
 public SpaIntro(IPublishedContent content)
 {
     Teaser = content.GetPropertyValue <string>(Constants.SkyConstants.Properties.Teaser);
     Image  = content.TypedMedia(Constants.SkyConstants.Properties.Image, SpaImage.GetFromContent);
 }