Exemplo n.º 1
0
        public IActionResult OnGet(string Slug)
        {
            MetaTags metaTags = new MetaTags(options);

            if (!string.IsNullOrEmpty(Slug))
            {
                if (!(Slug.Contains(".jpg") && Slug.Contains(".png")))
                {
                    post = repositoryData.GetPostBySlug(Slug);
                    if (post == null)
                    {
                        return(RedirectToPage("./NotFound"));
                    }

                    PostID = post.Id;

                    Comment = repositoryData.GetCommentsByPostId(post.Id);

                    string WebDomainName = options.Value.BaseUrl;
                    metaTags.Title           = string.IsNullOrEmpty(post.MetaTitle) ? post.Title : post.MetaTitle;
                    metaTags.FeaturedImg     = "mediaUpload/" + post.FeaturedImg;
                    metaTags.Web_Url         = WebDomainName + Slug;
                    metaTags.Description     = post.MetaDescription;
                    metaTags.ModifyDate      = post.ModifiedDate.ToString("s");
                    metaTags.PublishDate     = post.PublishDate.ToString("s");
                    metaTags.Keywords        = post.MetaKeyword;
                    metaTags.PrimaryCategory = post.PrimaryCategoryId.ToString();

                    LastUpdatedDate = post.ModifiedDate.ToString("MMMM") + " " + post.ModifiedDate.ToString("dd") + ", " + post.ModifiedDate.ToString("yyyy");
                }
            }
            else
            {
                HomePagePostList = repositoryData.GetHomePageList();
            }



            MyMetaTags = metaTags;
            return(Page());
        }