Created
May 11, 2020 07:45
-
-
Save AThraen/f6c83e89e64efb6461e1091af9ca8cef to your computer and use it in GitHub Desktop.
Using Wyam to build a blog website from an RssFeed
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
| <html> | |
| <head> | |
| <title>@ViewBag.Title</title> | |
| </head> | |
| <body> | |
| @RenderBody() | |
| </body> | |
| </html> |
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
| @{ | |
| Layout = "_Layout.cshtml"; | |
| } |
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
| // This directive installs packages from NuGet and is what you would normally use | |
| #n Wyam.Razor | |
| // This directive loads modules directly from the local build and is used for testing | |
| // NOTE: If running the example against modules built from source, call wyam.exe from the Wyam.Examples.Tests/bin/Debug folder | |
| #a **/* | |
| // Normalize the culture for the examples so they produce the same output regardless of system culture | |
| System.Globalization.CultureInfo.DefaultThreadCurrentCulture | |
| = System.Globalization.CultureInfo.CreateSpecificCulture("en-US"); | |
| Pipelines.Add("Posts", | |
| Download("https://www.codeart.dk/blog/rss/"), | |
| Xml("//item"), | |
| Merge(ReadFiles("post/post.cshtml")), | |
| Razor(), | |
| Index(), | |
| Title(@doc["title"]), | |
| Meta("PostFile",string.Format(@"posts\{0}.html", @doc["Index"])), | |
| WriteFiles((string)@doc["PostFile"]) | |
| ); | |
| Pipelines.Add("Home", | |
| ReadFiles("home.cshtml"), | |
| Razor(), | |
| WriteFiles(".html") | |
| ); |
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
| @{ViewBag.Title="Blog posts";} | |
| <h1>Blog posts from CodeArt</h1> | |
| @foreach(var doc in Documents["Posts"].OrderBy(x => x["Title"])) | |
| { | |
| <ul> | |
| <li><a href="@doc["PostFile"]">@doc["Title"]</a> - @doc["pubDate"]</li> | |
| </ul> | |
| } |
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
| @{ | |
| ViewBag.Title=Metadata["Title"]; | |
| } | |
| <h1 style="color:red">@Metadata["Title"]</h1> | |
| <h2>@Metadata["pubDate"]</h2> | |
| <hr /> | |
| <p>@Metadata["description"]</p> | |
| <a href="@Metadata["link"]">Read more...</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment