Skip to content
This repository has been archived by the owner on Feb 13, 2025. It is now read-only.

Commit

Permalink
Update main.html
Browse files Browse the repository at this point in the history
  • Loading branch information
lgor360 authored Jan 8, 2025
1 parent 45f0f53 commit 581820a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@
return data.posts;
}

function parseMarkdownLinks(text) {
// ищем ссылки в формате [текст](ссылка)
return text.replace(/\[([^\]]+)\]\((https?:\/\/[^\)]+)\)/g, '<a href="$2" target="_blank">$1</a>');
}

// функция для отображения постов
function renderPosts(posts) {
const postsContainer = document.getElementById("posts");
Expand All @@ -148,7 +153,7 @@
</div>
</div>
<div class="post-name">${post.post.name}</div>
<div class="post-text">${post.post.body}</div>
<div class="post-text">${parseMarkdownLinks(post.post.body || "")}</div>
${post.post.thumbnail_url ? `<img src="${post.post.thumbnail_url}" class="post-image" alt="картинка">` : ""}
<div class="post-footer">
<div class="counter">👍 <span>${post.counts.score}</span></div>
Expand Down

0 comments on commit 581820a

Please sign in to comment.