using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using OliverBooth.Common.Data.Web; using OliverBooth.Common.Services; namespace OliverBooth.Pages.Tutorials; public class Index : PageModel { private readonly ITutorialService _tutorialService; /// /// Initializes a new instance of the class. /// /// The tutorial service. public Index(ITutorialService tutorialService) { _tutorialService = tutorialService; } public ITutorialFolder? CurrentFolder { get; private set; } public void OnGet([FromRoute(Name = "slug")] string? slug) { if (slug is null) return; string[] tokens = slug.Split('/'); ITutorialFolder? folder = null; foreach (string token in tokens) { folder = _tutorialService.GetFolder(token, folder); } CurrentFolder = folder; } }