From eb9b29d30198c25d58476456e8454c90cfbe62f1 Mon Sep 17 00:00:00 2001 From: Oleksandr Kozachuk Date: Wed, 4 Jun 2025 10:28:00 +0200 Subject: [PATCH] Handle links properly. --- index.html | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 942f951..f47c3be 100644 --- a/index.html +++ b/index.html @@ -48,7 +48,16 @@ pointer-events: none; z-index: -1; } + a { + color: var(--accent-primary); + text-decoration: underline; + } + .idea-description a, + .tour-info a { + /* ensure they stand out against the dark bg */ + color: var(--accent-primary); + } .container { max-width: 1200px; margin: 0 auto; @@ -110,17 +119,26 @@ } .date-row { - display: -webkit-flex; display: flex; gap: 24px; } .date-row .form-group { - -webkit-flex: 0 0 calc((100% - 42px) / 2); - flex: 0 0 calc((100% - 42px) / 2); + width: calc((100% - 42px) / 2); min-width: 0; } + @media (max-width: 600px) { + .date-row { + flex-direction: column; + gap: 20px; + } + + .date-row .form-group { + flex: 1; + } + } + /* Forms */ .form-group { margin-bottom: 20px; @@ -503,6 +521,21 @@ // Listen for hash changes window.addEventListener('hashchange', checkForTourId); } + + function linkify(text) { + if (!text) return ''; + return text.replace( + /(\[([^\]]+)\]\((https?:\/\/[^\s)]+)\))|(https?:\/\/[^\s]+)/g, + (match, mdFull, mdLabel, mdUrl, plainUrl) => { + if (mdUrl) { + // matched [label](url) + return `${mdLabel}`; + } + // matched a bare URL + return `${plainUrl}`; + } + ); + } // Create new tour async function createTour(e) { @@ -695,7 +728,7 @@ tourInfo.innerHTML = `

${currentTour.name}

${dateHTML} -

${currentTour.description}

+

${linkify(currentTour.description)}

`; renderIdeas(); @@ -763,7 +796,7 @@ card.innerHTML = `

${idea.name}

${timeBadge} -

${idea.description}

+

${linkify(idea.description)}

👍 ${idea.voters.length} votes