Compare commits
2 commits
43355f4377
...
be1f02e1d9
Author | SHA1 | Date | |
---|---|---|---|
Laura Hausmann | be1f02e1d9 | ||
Laura Hausmann | e010feaaba |
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -186,4 +186,4 @@ Temporary Items
|
|||
database.db
|
||||
.bearer_token
|
||||
|
||||
Pages/blog/posts/drafts
|
||||
Posts/drafts
|
||||
|
|
|
@ -41,4 +41,4 @@ app.UseAuthorization();
|
|||
app.MapRazorPages();
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
app.Run();
|
|
@ -1,7 +1,7 @@
|
|||
using System.ServiceModel.Syndication;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using zotanpw.Backend;
|
||||
using zotanpw.Pages.blog;
|
||||
using zotanpw.Pages;
|
||||
|
||||
namespace zotanpw.Controllers;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using zotanpw.Pages.blog;
|
||||
using zotanpw.Pages;
|
||||
using J = System.Text.Json.Serialization.JsonPropertyNameAttribute;
|
||||
|
||||
namespace zotanpw.Controllers;
|
||||
|
|
|
@ -8,13 +8,13 @@ using Microsoft.AspNetCore.Mvc.RazorPages;
|
|||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization.NamingConventions;
|
||||
|
||||
namespace zotanpw.Pages.blog;
|
||||
namespace zotanpw.Pages;
|
||||
|
||||
public class BlogModel : PageModel {
|
||||
public static readonly List<BlogPost> Posts = new();
|
||||
|
||||
static BlogModel() {
|
||||
foreach (var file in Directory.EnumerateFiles("Pages/blog/posts"))
|
||||
foreach (var file in Directory.EnumerateFiles("Posts"))
|
||||
if (file.EndsWith(".md"))
|
||||
Posts.Add(new BlogPost(Path.GetFileNameWithoutExtension(file)));
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class BlogModel : PageModel {
|
|||
}
|
||||
|
||||
public void UpdateContentAndMetadata() {
|
||||
var markdownText = System.IO.File.ReadAllText($"Pages/blog/posts/{Shorthand}.md");
|
||||
var markdownText = System.IO.File.ReadAllText($"Posts/{Shorthand}.md");
|
||||
|
||||
var parsed = ParseBlogPost(markdownText);
|
||||
Title = parsed.metadata.Title!;
|
|
@ -1,6 +1,6 @@
|
|||
@page "/blog/{post}"
|
||||
@model BlogPostModel
|
||||
@using zotanpw.Backend
|
||||
@model BlogPostModel
|
||||
|
||||
@{
|
||||
if (Model.Post == null)
|
|
@ -1,20 +1,18 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace zotanpw.Pages.blog;
|
||||
namespace zotanpw.Pages;
|
||||
|
||||
public class BlogPostModel : PageModel {
|
||||
public BlogModel.BlogPost? Post;
|
||||
|
||||
public IActionResult OnGet() {
|
||||
if (string.IsNullOrWhiteSpace((string)RouteData.Values["post"]!)) {
|
||||
if (string.IsNullOrWhiteSpace((string)RouteData.Values["post"]!))
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
Post = BlogModel.Posts.FirstOrDefault(p => p.Shorthand == (string)RouteData.Values["post"]!);
|
||||
if (Post == null) {
|
||||
if (Post == null)
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
return Page();
|
||||
}
|
|
@ -24,4 +24,4 @@ else {
|
|||
<p>
|
||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||
</p>
|
||||
}
|
||||
}
|
|
@ -25,4 +25,4 @@
|
|||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
</table>
|
|
@ -57,4 +57,4 @@
|
|||
@await RenderSectionAsync("postfooter", false)
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
|
@ -8,28 +8,28 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="linq2db" Version="4.3.0" />
|
||||
<PackageReference Include="Markdig" Version="0.30.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.0" />
|
||||
<PackageReference Include="System.Data.SQLite" Version="1.0.115" />
|
||||
<PackageReference Include="System.ServiceModel.Syndication" Version="7.0.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="12.0.2" />
|
||||
<PackageReference Include="linq2db" Version="4.3.0"/>
|
||||
<PackageReference Include="Markdig" Version="0.30.4"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="7.0.0"/>
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="7.0.0"/>
|
||||
<PackageReference Include="System.Data.SQLite" Version="1.0.115"/>
|
||||
<PackageReference Include="System.ServiceModel.Syndication" Version="7.0.0"/>
|
||||
<PackageReference Include="YamlDotNet" Version="12.0.2"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove=".gitignore" />
|
||||
<None Remove=".bearer_token" />
|
||||
<None Remove="database.db" />
|
||||
<None Remove=".gitignore"/>
|
||||
<None Remove=".bearer_token"/>
|
||||
<None Remove="database.db"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<_ContentIncludedByDefault Remove="Pages\ErrorPages\404.cshtml" />
|
||||
<_ContentIncludedByDefault Remove="Pages\ErrorPages\404.cshtml"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="SetSourceRevisionId" BeforeTargets="InitializeSourceControlInformation">
|
||||
<Exec Command="git describe --long --always --dirty --exclude=* --abbrev=8" ConsoleToMSBuild="True" IgnoreExitCode="False">
|
||||
<Output PropertyName="SourceRevisionId" TaskParameter="ConsoleOutput" />
|
||||
<Output PropertyName="SourceRevisionId" TaskParameter="ConsoleOutput"/>
|
||||
</Exec>
|
||||
</Target>
|
||||
|
||||
|
|
Loading…
Reference in a new issue