Renders the markdown documents in Content/Socialism: a landing overview at
/socialism and chapters at /socialism/{slug}, with a sectioned sidebar,
on-page table of contents, prev/next paging and cross-document links.
Pages are noindex and nothing on the site links to them. Underscore-prefixed
files (founding draft, progress log) are never served, deployed or committed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
32 lines
1001 B
C#
32 lines
1001 B
C#
using JoshHeaps.Net.Models;
|
|
using JoshHeaps.Net.Services.Implementations;
|
|
using JoshHeaps.Net.Services.Interfaces;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace JoshHeaps.Net.Pages.Socialism;
|
|
|
|
public class DocModel(ISocialismDocService docService) : SocialismPageModel
|
|
{
|
|
public SocialismDoc? Doc { get; private set; }
|
|
public SocialismDoc? Previous { get; private set; }
|
|
public SocialismDoc? Next { get; private set; }
|
|
|
|
public IActionResult OnGet(string slug)
|
|
{
|
|
if (slug == SocialismDocService.IndexSlug)
|
|
return RedirectPermanent("/socialism");
|
|
|
|
Doc = docService.GetDoc(slug);
|
|
if (Doc is null)
|
|
return NotFound();
|
|
|
|
CurrentSlug = slug;
|
|
AllDocs = docService.GetAllDocs();
|
|
|
|
var position = AllDocs.FindIndex(d => d.Slug == slug);
|
|
Previous = position > 0 ? AllDocs[position - 1] : null;
|
|
Next = position >= 0 && position < AllDocs.Count - 1 ? AllDocs[position + 1] : null;
|
|
return Page();
|
|
}
|
|
}
|