Skip to content

Commit

Permalink
refactor: shorten view references, rename controller to match vsa style
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexZeitler committed Jan 22, 2024
1 parent b6bcd0f commit 6d5fc40
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 27 deletions.
10 changes: 10 additions & 0 deletions src/AspNetCoreMvcHtmx/Features/GetHome/GetHome.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Microsoft.AspNetCore.Mvc;

namespace AspNetCoreMvcHtmx.Features.GetHome;

public class GetHomeController(ILogger<GetHomeController> logger) : Controller
{
private readonly ILogger<GetHomeController> _logger = logger;

public IActionResult GetHome() => View();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@{
Layout = "~/Layouts/_Layout.cshtml";
ViewData["Title"] = "Home Page";
}

Expand Down
20 changes: 0 additions & 20 deletions src/AspNetCoreMvcHtmx/Features/Home/HomeController.cs

This file was deleted.

8 changes: 4 additions & 4 deletions src/AspNetCoreMvcHtmx/Layouts/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a asp-action="Index"
<a asp-action="GetHome"
asp-area=""
asp-controller="Home"
asp-controller="GetHome"
class="navbar-brand">TailwindVSA</a>
<button aria-controls="navbarSupportedContent"
aria-expanded="false"
Expand All @@ -29,9 +29,9 @@
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a asp-action="Index"
<a asp-action="GetHome"
asp-area=""
asp-controller="Home"
asp-controller="GetHome"
class="nav-link text-dark">Home</a>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreMvcHtmx/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}"
pattern: "{controller=GetHome}/{action=GetHome}/{id?}"
);

app.Run();
2 changes: 1 addition & 1 deletion src/AspNetCoreMvcHtmx/_ViewStart.cshtml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@{
Layout = "~/Layouts/_Layout.cshtml";
Layout = "_Layout";
}

0 comments on commit 6d5fc40

Please sign in to comment.