-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add regex to get links from markdown and render them correctly
- Loading branch information
1 parent
d77e36c
commit f528df8
Showing
2 changed files
with
76 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,72 @@ | ||
--- | ||
layout: default | ||
--- | ||
<div class="cover" style="z-index: 20"> | ||
<h3 class="cohort_title">{{ page.title }}</h3> | ||
|
||
<div class="program"> | ||
{% include partials/gsoc-community.html %} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>{{ page.title }}</title> | ||
<script src="/js/linkify.js" defer></script> | ||
</head> | ||
|
||
<div class="project-details"> | ||
<div class="card-content"> | ||
{{ page.video_embed }} | ||
</div> | ||
|
||
<h5 class="black-text heading">Project Ideas</h5> | ||
{% if page.projects %} | ||
<ul class="project-item"> | ||
{% for project in page.projects %} | ||
<li> | ||
<strong>{{ project.name }}</strong><br> | ||
{{ project.description | markdownify }} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
<body> | ||
<div class="cover" style="z-index: 20"> | ||
<h3 class="cohort_title">{{ page.title }}</h3> | ||
|
||
{% if page.recommended_skills %} | ||
<h3 class="project-list">Recommended Skills:</h3> | ||
<p class="program-p">{{ page.recommended_skills }}</p> | ||
{% endif %} | ||
<div class="program"> | ||
<div class="community-details"> | ||
{% include partials/gsoc-community.html %} | ||
</div> | ||
|
||
{% if page.mentors %} | ||
<h3 class="project-list">Mentors:</h3> | ||
<ul> | ||
{% for mentor in page.mentors %} | ||
<li>{{ mentor }}</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
<div class="project-details"> | ||
<div class="card-content"> | ||
<div class="image-div">{{ page.video_embed }}</div> | ||
</div> | ||
|
||
{% if page.issues %} | ||
<h3 class="project-list">Issue(s):</h3> | ||
{% for issue_link in page.issues %} | ||
<a class="issue" href="{{ issue_link }}">{{ issue_link }}</a><br /> | ||
{% endfor %} | ||
{% endif %} | ||
{% if page.projects %} | ||
<h5 class="black-text heading">Project Ideas</h5> | ||
{% for project in page.projects %} | ||
<ul class="project-item"> | ||
<ol> | ||
<b class="replace-links">{{ project.name }}</b> | ||
</ol> | ||
<ol class="replace-links"> | ||
{{ project.description }} | ||
</ol> | ||
</ul> | ||
{% endfor %} {% endif %} {% if page.recommended_skills %} | ||
<h3 class="project-list">Recommended Skills:</h3> | ||
<p class="program-p replace-links">{{ page.recommended_skills }}</p> | ||
{% endif %} {% if page.mentors %} | ||
<h3 class="project-list">Mentors:</h3> | ||
<ul> | ||
{% for mentor in page.mentors %} | ||
<li style="padding-bottom: 1rem" class="replace-links"> | ||
- {{ mentor }} | ||
</li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} {% if page.issues %} | ||
<h3 class="project-list">Issue:</h3> | ||
{% for issue_link in page.issues %} | ||
<a class="issue" href="{{ issue_link }}">{{ issue_link }}</a><br /> | ||
{% endfor %} {% endif %} | ||
|
||
<br /> | ||
<a href="https://slack.meshery.io"> | ||
<input type="button" value="Participate" class="participate-btn appear" /> | ||
</a> | ||
<br /> | ||
<a href="https://slack.meshery.io"> | ||
<input | ||
type="button" | ||
value="Participate" | ||
class="participate-btn appear" | ||
/> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="text subscribe program__subscribe"> | ||
{% include subscribe.html %} | ||
</div> | ||
<div class="text subscribe program__subscribe"> | ||
{% include subscribe.html %} | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
// Regex pattern to match [text](link) | ||
const linkPattern = /\[([^\]]+)\]\(([^\)]+)\)/g; | ||
|
||
// Find all elements that might contain the [label](url) pattern | ||
const elementsToReplace = document.querySelectorAll(".replace-links"); | ||
|
||
elementsToReplace.forEach((el) => { | ||
const originalText = el.textContent; | ||
const newHTML = originalText.replace(linkPattern, (match, label, url) => { | ||
return `<a href="${url}">${label}</a>`; | ||
}); | ||
el.innerHTML = newHTML; | ||
}); | ||
}); |