make string before start

This commit is contained in:
Tommy Parnell
2022-03-02 14:08:24 -05:00
parent 25f0c83300
commit 1c10d8ff6d
9 changed files with 19 additions and 6 deletions

View File

@@ -32,7 +32,10 @@ namespace TerribleDev.Blog.Web.Controllers
{
return Redirect($"/404/?from=/page/{pageNumber}/");
}
return View(new HomeViewModel() { Posts = result, Page = pageNumber, HasNext = postCache.PostsByPage.ContainsKey(pageNumber + 1), HasPrevious = postCache.PostsByPage.ContainsKey(pageNumber - 1), BlogLD = postCache.BlogLD, SiteLD = postCache.SiteLD });
return View(new HomeViewModel() { Posts = result, Page = pageNumber, HasNext = postCache.PostsByPage.ContainsKey(pageNumber + 1), HasPrevious = postCache.PostsByPage.ContainsKey(pageNumber - 1),
BlogLD = postCache.BlogLD,
SiteLD = postCache.SiteLD,
BlogLDString = postCache.BlogLDString, SiteLDString = postCache.SiteLDString });
}
[Route("/theme/{postName?}")]
public IActionResult Theme(string postName)

View File

@@ -97,7 +97,9 @@ namespace TerribleDev.Blog.Web.Factories
PostsByPage = postsByPage,
PostsAsSyndication = syndicationPosts,
BlogLD = ld,
SiteLD = website
SiteLD = website,
BlogLDString = ld.ToHtmlEscapedString().Replace("https://schema.org", "https://schema.org/true"),
SiteLDString = website.ToHtmlEscapedString().Replace("https://schema.org", "https://schema.org/true")
};
}

View File

@@ -94,7 +94,8 @@ namespace TerribleDev.Blog.Web
Summary = new HtmlString(summary),
SummaryPlain = postSummaryPlain,
SummaryPlainShort = (postContentPlain.Length <= 147 ? postContentPlain : postContentPlain.Substring(0, 146)) + "..." ,
JsonLD = ld
JsonLD = ld,
JsonLDString = ld.ToHtmlEscapedString().Replace("https://schema.org", "https://schema.org/true")
};
}),
};

View File

@@ -13,5 +13,7 @@ namespace TerribleDev.Blog.Web.Models
public Schema.NET.Blog BlogLD { get; set; }
public Schema.NET.WebSite SiteLD { get; set; }
public string BlogLDString { get; set; }
public string SiteLDString { get; set; }
}
}

View File

@@ -15,5 +15,7 @@ namespace TerribleDev.Blog.Web.Models
IList<string> Images { get; set; }
BlogPosting JsonLD { get; set; }
public string JsonLDString { get; set; }
}
}

View File

@@ -13,6 +13,8 @@ namespace TerribleDev.Blog.Web.Models
public Schema.NET.Blog BlogLD { get; set; }
public Schema.NET.WebSite SiteLD { get; set; }
public string BlogLDString { get; set; }
public string SiteLDString { get; set; }
}
}

View File

@@ -15,5 +15,6 @@ namespace TerribleDev.Blog.Web.Models
public string SummaryPlainShort { get; set; }
public IList<string> Images { get; set; }
public BlogPosting JsonLD { get; set; }
public string JsonLDString { get; set; }
}
}

View File

@@ -25,10 +25,10 @@
@section Head {
<partial name="StockMeta" />
<script type="application/ld+json">
@Html.Raw(Model.BlogLD.ToHtmlEscapedString())
@Html.Raw(Model.BlogLDString)
</script>
<script type="application/ld+json">
@Html.Raw(Model.SiteLD.ToHtmlEscapedString().Replace("https://schema.org", "https://schema.org/true"))
@Html.Raw(Model.SiteLDString)
</script>
}

View File

@@ -32,6 +32,6 @@
}
<meta property="og:image" content="https://www.gravatar.com/avatar/333e3cea32cd17ff2007d131df336061?s=640" />
<script type="application/ld+json">
@Html.Raw(Model.Content.Value.JsonLD.ToHtmlEscapedString())
@Html.Raw(Model.Content.Value.JsonLDString)
</script>
}