fixes gallery

This commit is contained in:
2026-02-26 07:27:20 +01:00
parent 0032aec02f
commit d3fd32b004
14 changed files with 316 additions and 217 deletions

View File

@@ -49,12 +49,15 @@ function renderMarkdownSafe(text) {
export default function ArtworkDescription({ artwork }) {
const [expanded, setExpanded] = useState(false)
const content = (artwork?.description || '').trim()
if (content.length === 0) return null
const collapsed = content.length > COLLAPSE_AT && !expanded
const visibleText = collapsed ? `${content.slice(0, COLLAPSE_AT)}` : content
const rendered = useMemo(() => renderMarkdownSafe(visibleText), [visibleText])
// useMemo must always be called (Rules of Hooks) — guard inside the callback
const rendered = useMemo(
() => (content.length > 0 ? renderMarkdownSafe(visibleText) : null),
[content, visibleText],
)
if (content.length === 0) return null
return (
<section className="rounded-xl bg-panel p-5 shadow-lg shadow-deep/30">