134 lines
4.4 KiB
Plaintext
134 lines
4.4 KiB
Plaintext
@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
|
|
|
|
<HeroSlider SliderItems="@sliders" PBottom="50px" Height="30vh"></HeroSlider>
|
|
|
|
@if (Content == null)
|
|
{
|
|
<p>Loading post...</p>
|
|
}
|
|
else
|
|
{
|
|
<div class="container">
|
|
|
|
<div class="card p-3" @onclick:stopPropagation>
|
|
@((MarkupString)Content)
|
|
</div>
|
|
|
|
@if (Tags?.Count > 0)
|
|
{
|
|
<p class="mt-3 text-muted small">
|
|
Tags: @string.Join(", ", Tags)
|
|
</p>
|
|
}
|
|
</div>
|
|
}
|
|
|
|
<CallToActionComponent></CallToActionComponent>
|
|
|
|
@code {
|
|
[Parameter]
|
|
public string PostId { get; set; }
|
|
|
|
private string? Content;
|
|
private string? Title;
|
|
private string? CoverImage;
|
|
private List<string>? 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 = "<p class='text-danger'>Failed to load blog post.</p>";
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
Content = "<p class='text-danger'>Invalid Google Drive link in post metadata.</p>";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
|
|
Content = "<p class='text-danger'>Failed to load blog post. " + e.ToString()+ "</p>";
|
|
}
|
|
}
|
|
|
|
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<HeroSliderItem> 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= ""
|
|
}
|
|
};
|
|
}
|