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"> <nav style="--bs-breadcrumb-divider: '>';" aria-label="breadcrumb">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="breadcrumb-item"> <li class="breadcrumb-item">
<a asp-area="blog" asp-page="/index">Blog</a> <a asp-page="/blog/index">Blog</a>
</li> </li>
<li class="breadcrumb-item active" aria-current="page">@post.Title</li> <li class="breadcrumb-item active" aria-current="page">@post.Title</li>
</ol> </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 Humanizer;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using OliverBooth.Data.Blog; using OliverBooth.Data.Blog;
using OliverBooth.Services; using OliverBooth.Services;
@ -12,7 +11,6 @@ namespace OliverBooth.Controllers;
[ApiController] [ApiController]
[Route("api/blog")] [Route("api/blog")]
[Produces("application/json")] [Produces("application/json")]
[EnableCors("BlogApi")]
public sealed class BlogApiController : ControllerBase public sealed class BlogApiController : ControllerBase
{ {
private readonly BlogService _blogService; private readonly BlogService _blogService;

View File

@ -34,11 +34,6 @@ builder.Services.AddDbContextFactory<WebContext>();
builder.Services.AddSingleton<BlogService>(); builder.Services.AddSingleton<BlogService>();
builder.Services.AddRazorPages().AddRazorRuntimeCompilation(); builder.Services.AddRazorPages().AddRazorRuntimeCompilation();
builder.Services.AddControllersWithViews(); 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.Services.AddRouting(options => options.LowercaseUrls = true);
builder.WebHost.UseKestrel(kestrel => builder.WebHost.UseKestrel(kestrel =>
@ -84,7 +79,6 @@ app.UseHttpsRedirection();
app.UseStaticFiles(); app.UseStaticFiles();
app.UseRouting(); app.UseRouting();
app.UseAuthorization(); app.UseAuthorization();
app.UseCors("BlogApi");
app.MapControllers(); app.MapControllers();
app.MapRazorPages(); app.MapRazorPages();

View File

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