using Microsoft.AspNetCore.Mvc.RazorPages;
using TaxBaik.Application.Services;

namespace TaxBaik.Web.Pages;

public class SitemapModel : PageModel
{
    private readonly BlogService _blogService;
    public List<string> Urls { get; set; } = [];

    public SitemapModel(BlogService blogService)
    {
        _blogService = blogService;
    }

    public async Task OnGetAsync()
    {
        var baseUrl = "http://178.104.200.7/taxbaik";
        Urls.AddRange(new[]
        {
            $"{baseUrl}",
            $"{baseUrl}/about",
            $"{baseUrl}/services",
            $"{baseUrl}/contact",
            $"{baseUrl}/blog"
        });

        var (posts, _) = await _blogService.GetPublishedPagedAsync(1, 1000);
        foreach (var post in posts)
        {
            Urls.Add($"{baseUrl}/blog/{post.Slug}");
        }
    }
}
