Section, dodanie sekcji z rozdzieleniem na standardowa i tą pod iframe

This commit is contained in:
dm
2025-11-21 07:17:05 +01:00
parent dafe9deaa6
commit f42a242d9c
17 changed files with 290 additions and 6 deletions

63
src/islands/Markdown.jsx Normal file
View File

@@ -0,0 +1,63 @@
import { marked } from "marked";
marked.setOptions({
gfm: true,
breaks: true,
headerIds: false,
mangle: false,
sanitize: false,
smartLists: true,
smartypants: false,
});
function applyShortcodes(md, ctx = {}) {
md = md.replace(/{{\s*channels\s*}}/g, () => {
if (!ctx.kanaly) return "";
const html = ctx.kanaly
.map(
(k) => `
<div class="flex items-center justify-center p-1">
<img
src="${k.logo}"
alt="${k.name}"
title="${k.name}"
class="channel-logo w-20 h-auto object-contain rounded"
/>
</div>
`
)
.join("");
return `
<div class="grid grid-cols-3 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-10 gap-2 my-4">
${html}
</div>
`;
});
return md;
}
export default function FuzMarkdown({ text, ctx = {} }) {
if (!text) return null;
let processed = applyShortcodes(text, ctx);
// Konwersja kinków na modal linki
processed = processed.replace(
/\[([^\]]+)\]\(#([^)]+)\)/g,
`<a href="#" class="modal-link text-cyan-600 underline" data-modal="$2">$1</a>`
);
const html = marked(processed);
return (
<div
class="fuz-markdown max-w-none"
dangerouslySetInnerHTML={{ __html: html }}
/>
);
}