Skip to content

Commit

Permalink
more formatting, also guard against github rate limit problems
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Drewery committed Jun 30, 2023
1 parent f20cdea commit 1b2b6b5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion content/making-a-blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ Probably doesn't require too much explanation as to what's going on here... its

But anyway, if its stupid and it works, then its not stupid! So, I'm happy with it. You can see the completed pipeline yaml file [here](https://github.com/adam-drewery/blog/blob/main/.github/workflows/build.yml).

I'll write another post at some point describing how I built the site itself. I had quite a bit of fun with it if I'm honest... frontend development has gotten more fun now I can delegate the tedious bits to ChatGPT. 😎
I'll write another post at some point describing how I built the site itself. I had quite a bit of fun with it if I'm honest... frontend development has gotten more enjoyable now I can delegate the tedious bits to ChatGPT. 😎
9 changes: 5 additions & 4 deletions site/Shared/Archives.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
<li>

<div>
<a href="/@post.Id">@post.Title</a>
</div>
<div>
<a style="font-size: x-small" href="/@post.Id">@post.Date</a>
<a href="/@post.Id">@post.Title

<div style="font-size: x-small" href="/@post.Id">@post.Date
</div>
</a>
</div>
</li>
}
Expand Down
26 changes: 16 additions & 10 deletions site/SiteContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,25 @@ public async Task Reload()

var posts = await _http.GetFromJsonAsync<IDictionary<string, PostDetails>>(indexUrl)
?? throw new InvalidDataException("Failed to get post index");

var commentDetails = await _http.GetFromJsonAsync<CommentDetails[]>(commentDetailsUrl)
?? throw new InvalidDataException("Failed to get comments");
try
{
var commentDetails = await _http.GetFromJsonAsync<CommentDetails[]>(commentDetailsUrl)
?? throw new InvalidDataException("Failed to get comments");

foreach (var postComments in commentDetails)
{
var title = postComments.Title.Split("/").Last();
var commentCount = postComments.Comments;

foreach (var postComments in commentDetails)
if (posts.TryGetValue(title, out var post))
post.CommentCount = commentCount;
}
}
catch (Exception e)
{
var title = postComments.Title.Split("/").Last();
var commentCount = postComments.Comments;

if (posts.TryGetValue(title, out var post))
post.CommentCount = commentCount;
Console.WriteLine(e);
}

foreach (var post in posts)
{
post.Value.Id = post.Key;
Expand Down

0 comments on commit 1b2b6b5

Please sign in to comment.