Compare commits

..

No commits in common. "9d0e16abc1db96c9ed03eb02f5cccfa80b07181a" and "cd0f38764d34b54e027688ee944498278c3a8031" have entirely different histories.

5 changed files with 5 additions and 22 deletions

View File

@ -19,7 +19,7 @@
<nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a asp-area="blog" asp-page="/index">Blog</a>
<a asp-page="/blog/index">Blog</a>
</li>
<li class="breadcrumb-item active" aria-current="page">@post.Title</li>
</ol>

View File

@ -1,2 +0,0 @@
@namespace OliverBooth.Areas.Blog.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -1,5 +1,4 @@
using Humanizer;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using OliverBooth.Data.Blog;
using OliverBooth.Services;
@ -12,7 +11,6 @@ namespace OliverBooth.Controllers;
[ApiController]
[Route("api/blog")]
[Produces("application/json")]
[EnableCors("BlogApi")]
public sealed class BlogApiController : ControllerBase
{
private readonly BlogService _blogService;

View File

@ -34,11 +34,6 @@ builder.Services.AddDbContextFactory<WebContext>();
builder.Services.AddSingleton<BlogService>();
builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
builder.Services.AddControllersWithViews();
builder.Services.AddCors(options => options.AddPolicy("BlogApi", policy => (builder.Environment.IsDevelopment()
? policy.AllowAnyOrigin()
: policy.WithOrigins("https://oliverbooth.dev"))
.AllowAnyMethod()
.AllowAnyHeader()));
builder.Services.AddRouting(options => options.LowercaseUrls = true);
builder.WebHost.UseKestrel(kestrel =>
@ -84,7 +79,6 @@ app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseCors("BlogApi");
app.MapControllers();
app.MapRazorPages();

View File

@ -1,7 +1,6 @@
import API from "./API";
import UI from "./UI";
import Input from "./Input";
import Author from "./Author";
const pkg = require("../../package.json");
@ -36,24 +35,18 @@ declare const Prism: any;
const blogPostContainer = UI.blogPostContainer;
if (blogPostContainer) {
const authors = [];
const template = Handlebars.compile(UI.blogPostTemplate.innerHTML);
API.getBlogPostCount().then(async (count) => {
for (let i = 0; i < count; i += 5) {
for (let i = 0; i < count; i++) {
const posts = await API.getBlogPosts(i, 5);
for (const post of posts) {
let author: Author;
if (authors[post.authorId]) {
author = authors[post.authorId];
} else {
author = await API.getAuthor(post.authorId);
authors[post.authorId] = author;
}
const author = await API.getAuthor(post.authorId);
const card = UI.createBlogPostCard(template, post, author);
blogPostContainer.appendChild(card);
UI.updateUI(card);
}
i += 4;
}
document.body.appendChild(UI.createDisqusCounterScript());