Handle links properly.
This commit is contained in:
parent
0331bdb9a9
commit
eb9b29d301
43
index.html
43
index.html
@ -48,7 +48,16 @@
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: -1;
|
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 {
|
.container {
|
||||||
max-width: 1200px;
|
max-width: 1200px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
@ -110,17 +119,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.date-row {
|
.date-row {
|
||||||
display: -webkit-flex;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 24px;
|
gap: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.date-row .form-group {
|
.date-row .form-group {
|
||||||
-webkit-flex: 0 0 calc((100% - 42px) / 2);
|
width: calc((100% - 42px) / 2);
|
||||||
flex: 0 0 calc((100% - 42px) / 2);
|
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 600px) {
|
||||||
|
.date-row {
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-row .form-group {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Forms */
|
/* Forms */
|
||||||
.form-group {
|
.form-group {
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
@ -503,6 +521,21 @@
|
|||||||
// Listen for hash changes
|
// Listen for hash changes
|
||||||
window.addEventListener('hashchange', checkForTourId);
|
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 `<a href="${mdUrl}" target="_blank" rel="noopener">${mdLabel}</a>`;
|
||||||
|
}
|
||||||
|
// matched a bare URL
|
||||||
|
return `<a href="${plainUrl}" target="_blank" rel="noopener">${plainUrl}</a>`;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Create new tour
|
// Create new tour
|
||||||
async function createTour(e) {
|
async function createTour(e) {
|
||||||
@ -695,7 +728,7 @@
|
|||||||
tourInfo.innerHTML = `
|
tourInfo.innerHTML = `
|
||||||
<h2 class="tour-title">${currentTour.name}</h2>
|
<h2 class="tour-title">${currentTour.name}</h2>
|
||||||
${dateHTML}
|
${dateHTML}
|
||||||
<p style="margin-top: 12px;">${currentTour.description}</p>
|
<p style="margin-top: 12px;">${linkify(currentTour.description)}</p>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
renderIdeas();
|
renderIdeas();
|
||||||
@ -763,7 +796,7 @@
|
|||||||
card.innerHTML = `
|
card.innerHTML = `
|
||||||
<h3 class="idea-title">${idea.name}</h3>
|
<h3 class="idea-title">${idea.name}</h3>
|
||||||
${timeBadge}
|
${timeBadge}
|
||||||
<p class="idea-description" style="margin-top: 8px;">${idea.description}</p>
|
<p class="idea-description" style="margin-top: 8px;">${linkify(idea.description)}</p>
|
||||||
<div class="vote-section">
|
<div class="vote-section">
|
||||||
<span class="vote-count">👍 ${idea.voters.length} votes</span>
|
<span class="vote-count">👍 ${idea.voters.length} votes</span>
|
||||||
<button class="btn btn-secondary btn-small" onclick="voteForIdea('${idea.id}')">Vote</button>
|
<button class="btn btn-secondary btn-small" onclick="voteForIdea('${idea.id}')">Vote</button>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user