@extends('layouts.public') @section('content') @php /** * CMS page renderer. Renders an admin-authored page through one of two * design-system templates, chosen by slug: * - privacy / terms → .qm-legal layout (sticky TOC + "Last updated" meta) * - everything else → .qm-article long-form prose card * * There was a third: an FAQ accordion assembled by walking the body's *

/

/

structure. It is gone with the FAQ page itself — the Help * Centre is the product's one FAQ surface, and it holds real question and * answer pairs instead of prose that had to be parsed back into them. * * The page body is sanitised on save (admin side); legal pages are structured * as

sections with a leading
' . $html . '
', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD ); libxml_clear_errors(); libxml_use_internal_errors($prev); if (!$ok) { return null; } $root = $doc->getElementById('qm-cms-root'); return $root instanceof DOMElement ? $root : null; }; /** Inner HTML of a DOM node (its children serialised). */ $innerHtml = static function (DOMNode $node): string { $html = ''; foreach ($node->childNodes as $child) { $html .= $node->ownerDocument->saveHTML($child); } return trim($html); }; /* ====================== LEGAL TEMPLATE (privacy/terms) ====================== */ if (in_array($slug, $legalSlugs, true)) { $toc = []; // [['id' => ..., 'label' => ...], ...] $lastUpdated = ''; // text pulled from a leading .qm-legal-meta paragraph $contentHtml = ''; $root = $loadDom($body); if ($root) { foreach ($root->childNodes as $node) { if ($node instanceof DOMElement) { $tag = strtolower($node->nodeName); // Lift a "Last updated …" meta line out of the body into the meta row. if ($lastUpdated === '' && $tag === 'p' && strpos((string) $node->getAttribute('class'), 'qm-legal-meta') !== false) { $lastUpdated = trim(strip_tags($innerHtml($node))); continue; } if ($tag === 'h2' && $node->getAttribute('id') !== '') { $toc[] = ['id' => $node->getAttribute('id'), 'label' => trim(strip_tags($innerHtml($node)))]; } } $contentHtml .= $root->ownerDocument->saveHTML($node); } } if (trim($contentHtml) === '') { $contentHtml = $body; } // Normalise a "Last updated: " prefix so the label reads cleanly. $lastUpdated = preg_replace('/^\s*last updated\s*:?\s*/i', '', $lastUpdated); @endphp @partial('subheader', [ 'type' => 'page', 'title' => $title, 'crumbs' => [['label' => t_raw('common.home'), 'url' => route('home')], ['label' => $title]], ])
@if ($toc) @endif @php return; } /* ======================= GENERIC ARTICLE TEMPLATE ======================= */ @endphp @partial('subheader', [ 'type' => 'page', 'title' => $title, 'crumbs' => [['label' => t_raw('common.home'), 'url' => route('home')], ['label' => $title]], ])
{{ $body /* admin-authored, sanitised on save */ }}
@endsection