Skip to content

Commit

Permalink
Merge pull request #287 from osmus/gh-pages
Browse files Browse the repository at this point in the history
decoding more fields
  • Loading branch information
d3netxer authored Jan 12, 2024
2 parents 3d50269 + c5f4d95 commit 9d639a0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% include navbar.html %}
<div class="blog-post content">
<div class="blog-post-title">
{{ page.title}}
{{ page.title }}
</div>
{% if page.author %}
<span class="blog-post-by-line">
Expand Down
24 changes: 23 additions & 1 deletion _layouts/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,22 @@ <h3>Education Activity Duration:</h3>
</div>


<div class="project-tags">
<!-- <div class="project-tags">
<p>Tags:&nbsp;</p>
<div class="card-tags">
{% for tag in page.tags %}
<span class="card-tag">{{ tag }}</span>
{% endfor %}
</div>
</div> -->

<div class="project-tags">
<p>Tags:&nbsp;</p>
<div class="card-tags" id="card-tags">
{% for tag in page.tags %}
<span class="card-tag" data-encoded-tag="{{ tag | url_decode }}">{{ tag | url_decode }}</span>
{% endfor %}
</div>
</div>

{% if page.video_link %}
Expand Down Expand Up @@ -225,10 +234,23 @@ <h3>Education Activity Duration:</h3>
let decodedDescription = decodeURIComponent(encodedDescription);

//console.log(decodedDescription)
//console.log('lets decode')

// Insert the decoded string into the HTML
document.getElementById('project-description').innerHTML = decodedDescription;

// Decode the fields
let decodedTitle = decodeURIComponent("{{ page.title }}");
let decodedSubtitle = decodeURIComponent("{{ page.subtitle }}");
let decodedAuthor = decodeURIComponent("{{ page.author }}");

//console.log('lets decode title')
//console.log(decodedTitle)
// Set the decoded strings into the HTML
document.querySelector('.project-title h1').textContent = decodedTitle;
document.querySelector('.project-title h3').textContent = decodedSubtitle;
document.querySelector('.project-title p').textContent = decodedAuthor;

</script>

<script>
Expand Down
14 changes: 10 additions & 4 deletions assets/js/custom/project-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,16 @@ class ProjectFilter {
url,
} = project;

let decodedTitle = decodeURIComponent(project.title);
let decodedSubtitle = decodeURIComponent(project.subtitle);
let decodedAuthor = decodeURIComponent(project.author);
// Decode URL-encoded description
let decodedDescription = decodeURIComponent(project.description);
// Then decode HTML entities
decodedDescription = decodeHtml(decodedDescription);
//decode tags
let decodedTags = project.tags.map(tag => decodeURIComponent(tag));


return `
<div class="project-card">
Expand All @@ -140,12 +146,12 @@ class ProjectFilter {
<div class="card-content">
<div class="card-title">
<a href="${project.url}"><h1><strong>Title: </strong>${title}</h1></a>
<h2><strong>Subtitle: </strong>${subtitle}</h2>
<a href="${project.url}"><h1><strong>Title: </strong>${decodedTitle}</h1></a>
<h2><strong>Subtitle: </strong>${decodedSubtitle}</h2>
<div class="card-container">
<div class="card-child">
<strong>Author: </strong>${author}
<strong>Author: </strong>${decodedAuthor}
</div>
<div class="card-child">
<strong>Date posted: </strong>${date_posted || '-'}
Expand All @@ -159,7 +165,7 @@ class ProjectFilter {
<div class="card-tags">
<p>Tags:&nbsp;</p>
${
tags
decodedTags
.map(tag => `<span class="card-tag">${tag}</span>`)
.join('')
}
Expand Down

0 comments on commit 9d639a0

Please sign in to comment.