@extends('layouts._site.main') @section('title', 'EcoFeminino - Detalhes') @section('content') @php use App\Models\Project; use App\Models\News; use Illuminate\Support\Str; $isNews = isset($news); $item = $isNews ? $news : $project; if ($isNews) { $related = $relatedNews ?? collect(); // Se não houver relacionados, pega 4 notícias recentes diferentes da atual if ($related->count() === 0) { $related = News::where('id', '!=', $item->id)->latest()->take(4)->get(); } } else { // Pega 4 projetos quaisquer diferentes do atual $related = Project::where('id', '!=', $item->id)->where('status', 'approved')->latest()->take(4)->get(); } @endphp
{{-- ========================= CABEÇALHO ========================= --}} @if ($isNews) {{ $item->category->name ?? 'Sem Categoria' }}

{{ $item->title }}

comment-icon {{ $item->created_at->format('d M, Y') }}
@else {{ ucfirst(strtolower($item->category ?? 'Projeto')) }}

{{ $item->project_name ?? $item->title }}

@if (!empty($item->organization)) @endif date-icon {{ $item->created_at->format('d M, Y') }}
@endif {{-- ========================= FIM CABEÇALHO ========================= --}}
{{ $item->project_name ?? $item->title }}
{{-- ========================= CONTEÚDO ========================= --}} @if ($isNews) {{-- ======== NOTÍCIA ======== --}} @if (isset($item->category) && Str::lower($item->category->name) === 'perfil inspirador') @if ($item->blocks && $item->blocks->count() > 0) @foreach ($item->blocks as $index => $block)
@if (!empty($block->imagem)) Imagem do perfil {{ $item->title }} @endif @if (!empty($block->texto))

{!! nl2br(e($block->texto)) !!}

@endif
@endforeach @elseif (!empty($item->description)) {!! nl2br(e($item->description)) !!} @else Sem Conteúdo Disponível para este Perfil. @endif @else {!! $item->description !!} @endif @else {{-- ======== PROJETO ======== --}} {{-- ======== PDF e Link do Projeto ======== --}} @if (!empty($item->pdf_path) || !empty($item->link))
@if (!empty($item->pdf_path))

Imprimir

PDF
@endif @if (!empty($item->link)) @endif
@endif {{-- ======== Descrição do Projeto ======== --}}
@php $paragraphs = preg_split("/\r\n|\n|\r/", trim($item->description)); @endphp @foreach ($paragraphs as $paragraph) @php $trimmed = trim($paragraph); @endphp @if ($trimmed === '') @continue @endif {{-- Linhas com ## viram h2 --}} @if (Str::startsWith($trimmed, '##'))

{{ trim(Str::replaceFirst('##', '', $trimmed)) }}

{{-- Linhas com ### viram h3 --}} @elseif (Str::startsWith($trimmed, '###'))

{{ trim(Str::replaceFirst('###', '', $trimmed)) }}

{{-- Linhas totalmente em maiúsculas viram h2 também --}} @elseif ($trimmed === Str::upper($trimmed) && strlen($trimmed) > 5)

{{ $trimmed }}

{{-- Senão, é um parágrafo normal --}} @else

{{ $trimmed }}

@endif @endforeach
{{-- Galeria de imagens do projeto --}} @if ($item->images && $item->images->count() > 0) @endif @endif
{{-- ========================= RELACIONADOS ========================= --}}
@if ($related->count() > 0) @else @endif
{{-- ========================= ESTILOS ========================= --}} {{-- ========================= SCRIPT ========================= --}} @endsection