@model BCards.Web.Models.IPageDisplay
@{
var seo = ViewBag.SeoSettings as BCards.Web.Models.SeoSettings;
var category = ViewBag.Category as BCards.Web.Models.Category;
var isPreview = ViewBag.IsPreview as bool? ?? false;
var isLivePage = ViewBag.IsLivePage as bool? ?? false;
ViewData["Title"] = seo?.Title ?? $"{Model.DisplayName} - {category?.Name}";
// Lógica de layout corrigida para usar o _PreviewLayout
Layout = isPreview ? "_PreviewLayout" : "_UserPageLayout";
}
@functions {
///
/// Normaliza URLs de redes sociais para garantir que sempre tenham protocolo HTTPS
/// Corrige URLs que foram salvas sem prefixo HTTP(S)
///
string NormalizeSocialUrl(string url, string icon)
{
if (string.IsNullOrEmpty(url)) return "#";
// WhatsApp - sempre normalizar para evitar URLs malformadas
if (!string.IsNullOrEmpty(icon) && icon.Contains("whatsapp"))
{
// Remove qualquer prefixo conhecido (incluindo https://)
var cleanUrl = url
.Replace("https://wa.me/", "")
.Replace("http://wa.me/", "")
.Replace("https://api.whatsapp.com/send?phone=", "")
.Replace("https://api.whatsapp.com/", "")
.Replace("wa.me/", "")
.Replace("whatsapp://send?phone=", "")
.Replace("whatsapp://", "");
// Remove barras extras
cleanUrl = cleanUrl.TrimStart('/').Trim();
// Apenas números devem sobrar
return $"https://wa.me/{cleanUrl}";
}
// Se já tem protocolo correto para outras redes, retorna direto
if (url.StartsWith("http://") || url.StartsWith("https://"))
return url;
// Facebook
if (!string.IsNullOrEmpty(icon) && icon.Contains("facebook"))
{
var cleanUrl = url
.Replace("https://facebook.com/", "")
.Replace("https://www.facebook.com/", "")
.Replace("https://fb.com/", "")
.Replace("https://www.fb.com/", "")
.Replace("http://facebook.com/", "")
.Replace("http://www.facebook.com/", "")
.Replace("facebook.com/", "")
.Replace("fb.com/", "")
.TrimStart('/').Trim();
return $"https://facebook.com/{cleanUrl}";
}
// Instagram
if (!string.IsNullOrEmpty(icon) && icon.Contains("instagram"))
{
var cleanUrl = url
.Replace("https://instagram.com/", "")
.Replace("https://www.instagram.com/", "")
.Replace("https://instagr.am/", "")
.Replace("http://instagram.com/", "")
.Replace("http://www.instagram.com/", "")
.Replace("instagram.com/", "")
.Replace("instagr.am/", "")
.TrimStart('/').Trim();
return $"https://instagram.com/{cleanUrl}";
}
// Twitter/X
if (!string.IsNullOrEmpty(icon) && (icon.Contains("twitter") || icon.Contains("x-twitter")))
{
var cleanUrl = url
.Replace("https://x.com/", "")
.Replace("https://twitter.com/", "")
.Replace("https://www.twitter.com/", "")
.Replace("https://www.x.com/", "")
.Replace("http://x.com/", "")
.Replace("http://twitter.com/", "")
.Replace("x.com/", "")
.Replace("twitter.com/", "")
.TrimStart('/').Trim();
return $"https://x.com/{cleanUrl}";
}
// TikTok
if (!string.IsNullOrEmpty(icon) && icon.Contains("tiktok"))
{
var cleanUrl = url
.Replace("https://tiktok.com/@", "")
.Replace("https://www.tiktok.com/@", "")
.Replace("https://tiktok.com/", "")
.Replace("https://www.tiktok.com/", "")
.Replace("https://vm.tiktok.com/", "")
.Replace("http://tiktok.com/@", "")
.Replace("http://tiktok.com/", "")
.Replace("tiktok.com/@", "")
.Replace("tiktok.com/", "")
.TrimStart('/').Trim();
// Se não tem @, adiciona
if (!cleanUrl.StartsWith("@"))
cleanUrl = "@" + cleanUrl;
return $"https://tiktok.com/{cleanUrl}";
}
// Pinterest
if (!string.IsNullOrEmpty(icon) && icon.Contains("pinterest"))
{
var cleanUrl = url
.Replace("https://pinterest.com/", "")
.Replace("https://www.pinterest.com/", "")
.Replace("https://pin.it/", "")
.Replace("http://pinterest.com/", "")
.Replace("http://www.pinterest.com/", "")
.Replace("pinterest.com/", "")
.Replace("pin.it/", "")
.TrimStart('/').Trim();
return $"https://pinterest.com/{cleanUrl}";
}
// Discord
if (!string.IsNullOrEmpty(icon) && icon.Contains("discord"))
{
var cleanUrl = url
.Replace("https://discord.gg/", "")
.Replace("https://discord.com/invite/", "")
.Replace("http://discord.gg/", "")
.Replace("http://discord.com/invite/", "")
.Replace("discord.gg/", "")
.Replace("discord.com/invite/", "")
.TrimStart('/').Trim();
return $"https://discord.gg/{cleanUrl}";
}
// Kawai ou qualquer outra rede não identificada
// Se contém domínio, apenas adiciona https://
if (url.Contains(".") || url.Contains("/"))
{
return $"https://{url.TrimStart('/')}";
}
// Fallback: assume que é uma URL completa que está faltando protocolo
return $"https://{url}";
}
}
@section Head {
@if (isLivePage)
{
@if (!string.IsNullOrEmpty(ViewBag.PageUrl as string))
{
}
}
else
{
// A meta tag de noindex/nofollow para previews já está no _PreviewLayout
}
}
@section Styles {
}
@if (!string.IsNullOrEmpty(Model.Bio))
{
@Model.Bio
}
@if (Model.Links?.Any(l => l.IsActive) == true)
{
@for (int i = 0; i < Model.Links.Count; i++)
{
var link = Model.Links[i];
if (link.IsActive)
{
var hasExpandableContent = (!string.IsNullOrEmpty(link.Description) ||
(link.Type == BCards.Web.Models.LinkType.Product && !string.IsNullOrEmpty(link.ProductDescription)));
@if (hasExpandableContent)
{
@if (link.Type == BCards.Web.Models.LinkType.Product)
{
@if (!string.IsNullOrEmpty(link.ProductImage))
{

}
@if (!string.IsNullOrEmpty(link.ProductPrice))
{
@link.ProductPrice
}
@if (!string.IsNullOrEmpty(link.ProductDescription))
{
@link.ProductDescription
}
}
else
{
@if (!string.IsNullOrEmpty(link.Description))
{
@link.Description
}
}
Clique no título acima para abrir
}
}
}
}
@* Documentos integrados no mesmo container de links *@
@if (Model.Documents?.Any() == true)
{
@for (int docIndex = 0; docIndex < Model.Documents.Count; docIndex++)
{
var document = Model.Documents[docIndex];
var hasDescription = !string.IsNullOrEmpty(document.Description);
var uniqueId = $"doc-{docIndex}";
@if (hasDescription)
{
@document.Description
Clique no título acima para abrir o PDF
}
}
}
@if ((Model.Links?.Any(l => l.IsActive) != true) && (Model.Documents?.Any() != true))
{
Nenhum link disponível no momento.
}
Escaneie para compartilhar esta página
@section Scripts {
}