|
11 | 11 | $pageDescription = $trainingResource->meta_description ?: $fallbackDescription; |
12 | 12 |
|
13 | 13 | $introClass = "text-[#20262C] font-normal text-lg md:text-xl p-0 mb-6 [&_p]:p-0 [&_p]:mb-6 [&_a]:text-dark-blue [&_a]:hover:underline"; |
14 | | - $contentClass = "text-[#333E48] font-normal text-lg md:text-xl p-0 mb-6 [&_p]:p-0 [&_p]:mb-6 [&_h2]:text-dark-blue [&_h2]:text-2xl [&_h2]:md:text-3xl [&_h2]:leading-[44px] [&_h2]:font-medium [&_h2]:font-['Montserrat'] [&_h2]:mb-4 [&_h3]:text-dark-blue [&_h3]:text-xl [&_h3]:md:text-2xl [&_h3]:font-medium [&_h3]:font-['Montserrat'] [&_h3]:mb-4 [&_ul]:pl-8 [&_ul]:m-0 [&_ul]:mb-6 [&_ul]:list-disc [&_ol]:pl-8 [&_ol]:m-0 [&_ol]:mb-6 [&_ol]:list-decimal [&_li]:p-0 [&_li]:text-lg [&_li]:font-normal [&_li]:leading-7 [&_li]:text-default [&_a]:text-dark-blue [&_a]:hover:underline [&_img]:max-w-full [&_img]:w-auto [&_img]:h-auto [&_img]:my-8 [&_img]:mx-auto [&_img]:block"; |
| 14 | + $contentClass = "text-[#333E48] font-normal text-lg md:text-xl p-0 mb-6 min-w-0 [&_p]:p-0 [&_p]:mb-6 [&_h2]:text-dark-blue [&_h2]:text-2xl [&_h2]:md:text-3xl [&_h2]:leading-[44px] [&_h2]:font-medium [&_h2]:font-['Montserrat'] [&_h2]:mb-4 [&_h3]:text-dark-blue [&_h3]:text-xl [&_h3]:md:text-2xl [&_h3]:font-medium [&_h3]:font-['Montserrat'] [&_h3]:mb-4 [&_ul]:pl-8 [&_ul]:m-0 [&_ul]:mb-6 [&_ul]:list-disc [&_ol]:pl-8 [&_ol]:m-0 [&_ol]:mb-6 [&_ol]:list-decimal [&_li]:p-0 [&_li]:text-lg [&_li]:font-normal [&_li]:leading-7 [&_li]:text-default [&_a]:text-dark-blue [&_a]:hover:underline [&_a]:break-words [&_img]:max-w-full [&_img]:w-auto [&_img]:h-auto [&_img]:my-8 [&_img]:mx-auto [&_img]:block [&_svg]:max-w-full [&_svg]:h-auto [&_svg]:block"; |
15 | 15 | $pdfClass = "text-[#333E48] font-normal text-lg md:text-xl p-0 mb-6 [&_p]:p-0 [&_p]:mb-4 [&_h2]:text-dark-blue [&_h2]:text-2xl [&_h2]:md:text-3xl [&_h2]:leading-[44px] [&_h2]:font-medium [&_h2]:font-['Montserrat'] [&_h2]:mb-4 [&_ul]:m-0 [&_ul]:mb-6 [&_ul]:list-none [&_ol]:m-0 [&_ol]:mb-6 [&_ol]:list-none [&_li]:p-0 [&_li]:mb-2 [&_li]:font-normal [&_li]:leading-7 [&_li]:text-default [&_li]:break-words [&_a]:text-lg [&_a]:text-dark-blue [&_a]:no-underline [&_a:hover]:underline [&_a]:break-words [&_a]:max-w-full"; |
16 | 16 | $contactsClass = "text-[#333E48] font-normal text-lg md:text-xl p-0 mb-8 [&_p]:p-0 [&_p]:mb-4 [&_h2]:text-dark-blue [&_h2]:text-2xl [&_h2]:md:text-3xl [&_h2]:leading-[44px] [&_h2]:font-medium [&_h2]:font-['Montserrat'] [&_h2]:mb-4 [&_a]:text-dark-blue [&_a]:hover:underline"; |
17 | 17 | $registerClass = "text-[#333E48] font-normal text-base md:text-lg [&_p]:p-0 [&_p]:mb-4 [&_p:last-child]:mb-0 [&_a]:font-medium [&_a]:text-dark-blue [&_a]:hover:underline"; |
|
26 | 26 |
|
27 | 27 | $renderedContent = $trainingResource->content ?? ''; |
28 | 28 | $roadmapEmbedUrl = trim((string) ($trainingResource->roadmap_pdf_embed_url ?? '')); |
29 | | - if ($roadmapEmbedUrl !== '' && str_contains($renderedContent, '[[embed_roadmap_pdf]]')) { |
30 | | - $renderedContent = str_replace( |
31 | | - '[[embed_roadmap_pdf]]', |
32 | | - view('training.partials.roadmap-pdf-embed', ['url' => $roadmapEmbedUrl])->render(), |
33 | | - $renderedContent |
34 | | - ); |
35 | | - } elseif (str_contains($renderedContent, '[[embed_roadmap_pdf]]')) { |
36 | | - $renderedContent = str_replace('[[embed_roadmap_pdf]]', '', $renderedContent); |
| 29 | + $roadmapEmbedKind = strtolower(trim((string) ($trainingResource->roadmap_embed_kind ?? 'pdf'))); |
| 30 | + if (! in_array($roadmapEmbedKind, ['pdf', 'svg', 'none'], true)) { |
| 31 | + $roadmapEmbedKind = 'pdf'; |
| 32 | + } |
| 33 | + $roadmapSvg = trim((string) ($trainingResource->roadmap_svg ?? '')); |
| 34 | +
|
| 35 | + $roadmapPlaceholders = ['[[embed_roadmap_pdf]]', '[[embed_roadmap]]']; |
| 36 | + $hasRoadmapPlaceholder = str_contains($renderedContent, '[[embed_roadmap_pdf]]') |
| 37 | + || str_contains($renderedContent, '[[embed_roadmap]]'); |
| 38 | +
|
| 39 | + if ($hasRoadmapPlaceholder) { |
| 40 | + $roadmapEmbedHtml = ''; |
| 41 | + if ($roadmapEmbedKind === 'pdf' && $roadmapEmbedUrl !== '') { |
| 42 | + $roadmapEmbedHtml = view('training.partials.roadmap-pdf-embed', ['url' => $roadmapEmbedUrl])->render(); |
| 43 | + } elseif ($roadmapEmbedKind === 'svg' && $roadmapSvg !== '') { |
| 44 | + $roadmapEmbedHtml = view('training.partials.roadmap-svg-embed', ['svg' => $roadmapSvg])->render(); |
| 45 | + } |
| 46 | +
|
| 47 | + foreach ($roadmapPlaceholders as $token) { |
| 48 | + if (str_contains($renderedContent, $token)) { |
| 49 | + $renderedContent = str_replace($token, $roadmapEmbedHtml, $renderedContent); |
| 50 | + } |
| 51 | + } |
37 | 52 | } |
38 | 53 | @endphp |
39 | 54 |
|
@@ -189,6 +204,31 @@ class="inline-block rounded-full py-2.5 px-6 border border-[#1C4DA1] text-[#1C4D |
189 | 204 | </section> |
190 | 205 | @endsection |
191 | 206 |
|
| 207 | +@push('scripts') |
| 208 | + <script> |
| 209 | + (function () { |
| 210 | + document.querySelectorAll('#codeweek-training-dynamic-subpage svg').forEach(function (svg) { |
| 211 | + if (svg.getAttribute('viewBox')) { |
| 212 | + return; |
| 213 | + } |
| 214 | + var w = svg.getAttribute('width'); |
| 215 | + var h = svg.getAttribute('height'); |
| 216 | + if (!w || !h) { |
| 217 | + return; |
| 218 | + } |
| 219 | + var wn = parseFloat(w); |
| 220 | + var hn = parseFloat(h); |
| 221 | + if (!(wn > 0 && hn > 0)) { |
| 222 | + return; |
| 223 | + } |
| 224 | + svg.setAttribute('viewBox', '0 0 ' + wn + ' ' + hn); |
| 225 | + svg.removeAttribute('width'); |
| 226 | + svg.removeAttribute('height'); |
| 227 | + }); |
| 228 | + })(); |
| 229 | + </script> |
| 230 | +@endpush |
| 231 | + |
192 | 232 | @if($anchorOffset > 0) |
193 | 233 | @push('scripts') |
194 | 234 | <script> |
|
0 commit comments