Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Faisal N committed Oct 10, 2023
1 parent 2e4e075 commit d294b18
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion frontend/pages/article.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<h1><%= article.title %></h1>
<% if (article.description != null) { %><h3><%= article.description.slice(0, 97) %>...</h3><% } %>
<h5><%= pageviews %> Views</h5>
<p>Tags: <% for (tag of article.tags) { %><a href="<%- vars.domain %>/tags/<%= tag %>"><%= toTitleCase(tag) %></a> <% } %></p>
<% if (article.tags != null) { %><p>Tags: <% for (tag of article.tags) { %><a href="<%- vars.domain %>/tags/<%= tag %>"><%= toTitleCase(tag) %></a> <% } %></p><% } %>
</div>
<div class="author">
<img src="<%- vars.asset_prefix %><%= cms.siteDetails[0].favicon.path %>" />
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/articles.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<h3><%= article.title %></h3>
</a>
<% if (article.description != null) { %><h4><%= article.description.slice(0, 97) %>...</h4><% } %>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
<p><% if (article.tags != null) { %><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% } %><% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
</div>
</div>
<% } %>
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/artwork.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="left">
<div class="info">
<h1><%= artwork.title %></h1>
<p>Tags: <% for (tag of artwork.tags) { %><a href="<%- vars.domain %>/tags/<%= tag %>"><%= toTitleCase(tag) %></a> <% } %></p>
<% if (artwork.tags != null) { %><p>Tags: <% for (tag of artwork.tags) { %><a href="<%- vars.domain %>/tags/<%= tag %>"><%= toTitleCase(tag) %></a> <% } %></p><% } %>
</div>
<div class="author">
<img src="<%- vars.asset_prefix %><%= cms.siteDetails[0].favicon.path %>" />
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/artworks.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<a href="<%- vars.domain %>/artworks/<%= artwork.slug %>">
<h3><%= artwork.title %></h3>
</a>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
<p><% if (artwork.tags != null) { %><a href="<%- vars.domain %>/tags/<%= artwork.tags[0].toLowerCase() %>"><%= artwork.tags[0] %></a> / <% } %><% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
</div>
</div>
<% } %>
Expand Down
4 changes: 2 additions & 2 deletions frontend/pages/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<h3><%= article.title %></h3>
</a>
<% if (article.description != null) { %><h4><%= article.description.slice(0, 97) %>...</h4><% } %>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
<p><% if (article.tags != null) { %><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% } %><% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
</div>
</div>
<% } %>
Expand All @@ -60,7 +60,7 @@
<a href="<%- vars.domain %>/artworks/<%= artwork.slug %>">
<h3><%= artwork.title %></h3>
</a>
<p><a href="<%- vars.domain %>/tags/<%= artwork.tags[0].toLowerCase() %>"><%= artwork.tags[0] %></a> / <% var date = new Date(artwork.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((artwork.author != "") && (artwork.author != null)) { %> / <%= artwork.author %><% } %></p>
<p><% if (artwork.tags != null) { %><a href="<%- vars.domain %>/tags/<%= artwork.tags[0].toLowerCase() %>"><%= artwork.tags[0] %></a> / <% } %><% var date = new Date(artwork.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((artwork.author != "") && (artwork.author != null)) { %> / <%= artwork.author %><% } %></p>
</div>
</div>
<% } %>
Expand Down
4 changes: 2 additions & 2 deletions frontend/pages/search.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<h3>Article: <%= article.title %></h3>
</a>
<% if (article.description != null) { %><h4><%= article.description.slice(0, 97) %>...</h4><% } %>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
<p><% if (tags != null) { %><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% } %><% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
</div>
</div>
<% }); %>
Expand Down Expand Up @@ -92,7 +92,7 @@
<a href="<%- vars.domain %>/artworks/<%= artwork.slug %>">
<h3>Artwork: <%= artwork.title %></h3>
</a>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
<p><% if (artwork.tags != null) { %><a href="<%- vars.domain %>/tags/<%= artwork.tags[0].toLowerCase() %>"><%= artwork.tags[0] %></a> / <% } %><% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
</div>
</div>
<% }); %>
Expand Down
8 changes: 6 additions & 2 deletions frontend/pages/tag.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<head>
<%- include('../partials/head.ejs'); %>
<% const filteredArticles = cms.articles.filter(article => {
return article.tags.includes(tag);
if (article.tags == null) {
return false;
} else {
return article.tags.includes(tag);
};
});
function ifYesterday(date) {
var yesterday = new Date();
Expand All @@ -28,7 +32,7 @@
<h3><%= article.title %></h3>
</a>
<h4><%= article.description.slice(0, 97) %>...</h4>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article._created * 1000); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %></p>
<p><% if (article.tags != null) { %><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% } %><% var date = new Date(article._created * 1000); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %></p>
</div>
</div>
<% }); } else { %>No articles found<% } %>
Expand Down
10 changes: 6 additions & 4 deletions frontend/pages/tags.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
}
var tags = {};
for (article of cms.articles) {
for (tag of article.tags) {
if (!tags[tag]) {
tags[tag] = [];
if (article.tags) {
for (tag of article.tags) {
if (!tags[tag]) {
tags[tag] = [];
};
tags[tag].push(article);
};
tags[tag].push(article);
};
};
function toTitleCase(str) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/partials/suggested.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function ifYesterday(date) {
<h3><%= article.title %></h3>
</a>
<% if (article.description != null) { %><h4><%= article.description.slice(0, 97) %>...</h4><% } %>
<p><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
<p><% if (article.tags != null) { %><a href="<%- vars.domain %>/tags/<%= article.tags[0].toLowerCase() %>"><%= article.tags[0] %></a> / <% } %><% var date = new Date(article.date); if (date.isToday()) { %>Today<% } else if (ifYesterday(date)) { %>Yesterday<% } else { %><%= date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) %><% } %><% if ((article.author != "") && (article.author != null)) { %> / <%= article.author %><% } %></p>
</div>
</div>
<% } %>
Expand Down

0 comments on commit d294b18

Please sign in to comment.