-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0bcde6e
commit 922078e
Showing
37 changed files
with
935 additions
and
110 deletions.
There are no files selected for viewing
This file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,39 @@ | ||
@page "/blog" | ||
@using Coding.Blog.Engine | ||
@using Coding.Blog.Engine.Extensions | ||
|
||
<h3>Blog</h3> | ||
|
||
<p>Under construction</p> | ||
<div class="container mb-3"> | ||
@if (!Posts.Any()) | ||
{ | ||
<p> | ||
<strong>Loading...</strong> | ||
</p> | ||
} | ||
else | ||
{ | ||
<div class="row row-cols-sm-1 row-cols-md-2 row-cols-lg-3 g-3"> | ||
@foreach (var (slug, post) in Posts) | ||
{ | ||
<div class="col"> | ||
<div class="card"> | ||
<a href="@($"post/{slug}")"> | ||
<img src=@post.Hero.ImgixUrl class="card-img-top" alt="hero"/> | ||
</a> | ||
<div class="card-body"> | ||
<h5 class="card-title">@post.Title</h5> | ||
<h6 class="card-subtitle text-muted">@post.DatePublished.ToShortDateString()</h6> | ||
<a href="@($"post/{slug}")" class="card-link">Read More</a> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
</div> | ||
} | ||
</div> | ||
|
||
@code { | ||
|
||
} | ||
[CascadingParameter(Name = "Posts")] | ||
private IDictionary<string, Post> Posts { get; set; } = new Dictionary<string, Post>(); | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
@page "/post/{Slug}" | ||
@inject NavigationManager _navigationManager | ||
@inject IResilientClient<Post> _postsClient; | ||
@inject IJSRuntime _js; | ||
@using Coding.Blog.Engine | ||
@using Coding.Blog.Engine.Clients | ||
@using Coding.Blog.Engine.Extensions | ||
|
||
@if (_selectedPost is null) | ||
{ | ||
<p> | ||
<strong>Loading...</strong> | ||
</p> | ||
} | ||
else | ||
{ | ||
<div class="container"> | ||
<div class="row justify-content-center"> | ||
<div class="col col-auto"> | ||
<h1>@_selectedPost!.Title</h1> | ||
</div> | ||
</div> | ||
<div class="row justify-content-center"> | ||
<div class="col col-auto"> | ||
<p class="text-muted">@_selectedPost!.DatePublished.ToShortDateString()</p> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="container overflow-hidden mb-3"> | ||
<div class="row justify-content-center"> | ||
<div class="col col-auto"> | ||
<img class="rounded mx-auto d-block img-fluid" src="@_selectedPost!.Hero.ImgixUrl" alt="hero"> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col"> | ||
<div>@(new MarkupString(_selectedPost!.Content))</div> | ||
</div> | ||
</div> | ||
<div class="row justify-content-between"> | ||
<div class="col col-auto"> | ||
@if (_selectedPost.Next is not null) | ||
{ | ||
<h6 class="text-muted">Next</h6> | ||
<a href="@($"post/{_selectedPost.Next.Slug}")"> | ||
<h5>@_selectedPost.Next.Title</h5> | ||
</a> | ||
} | ||
</div > | ||
<div class="col col-auto"> | ||
@if (_selectedPost.Previous is not null) | ||
{ | ||
<h6 class="text-muted">Previous</h6> | ||
<a href="@($"post/{_selectedPost.Previous.Slug}")"> | ||
<h5>@_selectedPost.Previous.Title</h5> | ||
</a> | ||
} | ||
</div> | ||
</div> | ||
<div class="row justify-content-center"> | ||
<div class="col col-auto"> | ||
<button class="btn btn-secondary btn-lg" @onclick="NavigateToMain">Back</button> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
|
||
@code { | ||
|
||
[Parameter] | ||
public string Slug { get; set; } = string.Empty; | ||
|
||
[CascadingParameter(Name = "Posts")] | ||
private IDictionary<string, Post> Posts { get; set; } = new Dictionary<string, Post>(); | ||
|
||
private Post? _selectedPost; | ||
|
||
protected override async Task OnInitializedAsync() => await Refresh(); | ||
|
||
protected override async Task OnParametersSetAsync() => await Refresh(); | ||
|
||
private async Task Refresh() | ||
{ | ||
await _js.InvokeVoidAsync("resetScrollPosition"); | ||
|
||
if (!Posts.Any()) | ||
{ | ||
var posts = await _postsClient.GetAsync(); | ||
|
||
Posts = posts.ToDictionary(post => post.Slug, post => post); | ||
} | ||
|
||
Posts.TryGetValue(Slug, out _selectedPost); | ||
} | ||
|
||
private void NavigateToMain() => _navigationManager.NavigateTo("blog"); | ||
} |
This file contains 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 file contains 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 file contains 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 file contains 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 file contains 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 file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/Coding.Blog/Client/wwwroot/css/bootstrap/bootstrap.min.css.map
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.