@php $_plain = preg_replace('/<(p|div|h[1-6]|li|br)\b[^>]*>/i', "\n", $doc->content); $_plain = strip_tags($_plain); $_plain = html_entity_decode($_plain, ENT_QUOTES | ENT_HTML5, 'UTF-8'); $_plain = preg_replace('/[ \t]+/', ' ', $_plain); // 橫向空白壓縮 $_plain = preg_replace('/\n{3,}/', "\n\n", $_plain); // 最多空一行 $_plain = implode("\n", array_map('trim', explode("\n", $_plain))); $snippet = \Illuminate\Support\Str::limit(trim($_plain), 400, '…'); $showUrl = route("{$routePrefix}.show", [$project, $doc]); $editUrl = auth()->user()?->can('contributeDoc', $project) ? route("{$routePrefix}.edit", [$project, $doc]) : null; @endphp
{{-- 主要內容 --}}
{{-- Badges --}} @if(!empty($doc->category) || !empty($doc->version) || ($doc->attachments_count ?? 0) > 0)
@if(!empty($doc->category)) {{ $doc->category->name }} @endif @if(!empty($doc->version)) {{ $doc->version->name }} @endif @if(($doc->attachments_count ?? 0) > 0) {{ $doc->attachments_count }} @endif
@endif {{-- 標題 --}} {{ $doc->title }} {{-- Meta --}}
{{ $doc->author?->name ?? '—' }} · {{ $doc->updated_at->format('Y-m-d') }}
{{-- 內容摘要 --}} @if($snippet)

{{ $snippet }}

@endif
{{-- 操作按鈕 --}}
閱讀 @if($editUrl)
@csrf @method('DELETE')
@endif