@page "/blogpost/{PostId}" @using TIAMSharedUI.Pages.Components @using TIAMSharedUI.Shared @using TIAMWebApp.Shared.Application.Models.ClientSide.UI @using TIAMWebApp.Shared.Application.Services @inject HttpClient Http @inject BlogService BlogService @if (Content == null) {

Loading post...

} else {
@((MarkupString)Content)
@if (Tags?.Count > 0) {

Tags: @string.Join(", ", Tags)

}
} @code { [Parameter] public string PostId { get; set; } private string? Content; private string? Title; private string? CoverImage; private List? Tags; protected override async Task OnParametersSetAsync() { try { var post = await BlogService.GetPostByIdAsync(PostId); if (post != null) { Title = post.Title; CoverImage = post.CoverImage; Tags = post.Tags; // ✅ Extract fileId from DriveLink: var fileId = ExtractGoogleDriveFileId(post.DriveLink); if (!string.IsNullOrEmpty(fileId)) { // string apiKey = "AIzaSyBLKx4XFpgX97sULTbtpyKA2Ca_ANrjxxs"; // your existing key // // string downloadUrl = $"https://www.googleapis.com/drive/v3/files/{fileId}?alt=media&key={apiKey}"; // string downloadUrl = $"https://drive.google.com/uc?export=download&id={fileId}"; // Content = await Http.GetStringAsync(downloadUrl); Content = null; // Optional: clear previous content while loading new try { Content = await Http.GetStringAsync($"/api/blog/postcontent/{PostId}"); } catch { Content = "

Failed to load blog post.

"; } } else { Content = "

Invalid Google Drive link in post metadata.

"; } } } catch (Exception e) { Content = "

Failed to load blog post. " + e.ToString()+ "

"; } } private string? ExtractGoogleDriveFileId(string driveLink) { try { // Works with typical Google Drive URLs var match = System.Text.RegularExpressions.Regex.Match(driveLink, @"\/d\/([^\/]+)"); return match.Success ? match.Groups[1].Value : null; } catch { return null; } } public List sliders = new() { new HeroSliderItem { Title = "Experience Hungary on Your Terms", Subtitle = "Discover the freedom of personalized travel with expert private transfers and curated inspiration.", ImageUrl = "https://images.unsplash.com/photo-1551867633-194f125bddfa?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", ButtonText = "Explore Our Programs", ButtonUrl= "/signature-ride-packages" }, new HeroSliderItem { Title = "Experience Hungary on Your Terms", Subtitle = "Discover the freedom of personalized travel with expert private transfers and curated inspiration.", ImageUrl = "https://images.unsplash.com/photo-1549877452-9c387954fbc2?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", ButtonText = "Book now", ButtonUrl= "/transfer" }, new HeroSliderItem { Title = "Experience Hungary on Your Terms", Subtitle = "", ImageUrl = "https://images.unsplash.com/photo-1507622560124-621e26755fb8?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", ButtonText = "", ButtonUrl= "" } }; }