Created
May 28, 2019 11:20
-
-
Save tristolliday/5b01e59d55db789915ebef1e88363064 to your computer and use it in GitHub Desktop.
Newtonsoft-Linq Structured Data(Json-LD) for FAQ Pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script type="application/ld+json"> | |
| @{ | |
| JObject structuredData = | |
| new JObject( | |
| new JProperty("@context", "https://schema.org"), | |
| new JProperty("@type", "FAQPage"), | |
| new JProperty("mainEntity", | |
| new JArray( | |
| from item in questions | |
| select new JObject( | |
| new JProperty("@type", "Question"), | |
| new JProperty("name", (string)(item.GetProperty("question").Value().ToString())), | |
| new JProperty("acceptedAnswer", | |
| new JObject( | |
| new JProperty("@type", "Answer"), | |
| new JProperty("text", (string)(item.GetProperty("answer").Value().ToString())) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ); | |
| } | |
| @Html.Raw(structuredData.ToString()) | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment