From d294b18860f49e779903d5891ee94e0df9fb7041 Mon Sep 17 00:00:00 2001 From: Faisal N Date: Tue, 10 Oct 2023 10:49:00 -0400 Subject: [PATCH] bug fix --- frontend/pages/article.ejs | 2 +- frontend/pages/articles.ejs | 2 +- frontend/pages/artwork.ejs | 2 +- frontend/pages/artworks.ejs | 2 +- frontend/pages/index.ejs | 4 ++-- frontend/pages/search.ejs | 4 ++-- frontend/pages/tag.ejs | 8 ++++++-- frontend/pages/tags.ejs | 10 ++++++---- frontend/partials/suggested.ejs | 2 +- 9 files changed, 21 insertions(+), 15 deletions(-) diff --git a/frontend/pages/article.ejs b/frontend/pages/article.ejs index d8dbeb8..6615cc7 100644 --- a/frontend/pages/article.ejs +++ b/frontend/pages/article.ejs @@ -23,7 +23,7 @@

<%= article.title %>

<% if (article.description != null) { %>

<%= article.description.slice(0, 97) %>...

<% } %>
<%= pageviews %> Views
-

Tags: <% for (tag of article.tags) { %><%= toTitleCase(tag) %> <% } %>

+ <% if (article.tags != null) { %>

Tags: <% for (tag of article.tags) { %><%= toTitleCase(tag) %> <% } %>

<% } %>
diff --git a/frontend/pages/articles.ejs b/frontend/pages/articles.ejs index 2764ae4..3eb56d7 100644 --- a/frontend/pages/articles.ejs +++ b/frontend/pages/articles.ejs @@ -25,7 +25,7 @@

<%= article.title %>

<% if (article.description != null) { %>

<%= article.description.slice(0, 97) %>...

<% } %> -

<%= article.tags[0] %> / <% 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 %><% } %>

+

<% if (article.tags != null) { %><%= article.tags[0] %> / <% } %><% 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 %><% } %>

<% } %> diff --git a/frontend/pages/artwork.ejs b/frontend/pages/artwork.ejs index d3fe49b..e2755c6 100644 --- a/frontend/pages/artwork.ejs +++ b/frontend/pages/artwork.ejs @@ -21,7 +21,7 @@

<%= artwork.title %>

-

Tags: <% for (tag of artwork.tags) { %><%= toTitleCase(tag) %> <% } %>

+ <% if (artwork.tags != null) { %>

Tags: <% for (tag of artwork.tags) { %><%= toTitleCase(tag) %> <% } %>

<% } %>
diff --git a/frontend/pages/artworks.ejs b/frontend/pages/artworks.ejs index 3dfa2f4..713e04c 100644 --- a/frontend/pages/artworks.ejs +++ b/frontend/pages/artworks.ejs @@ -24,7 +24,7 @@

<%= artwork.title %>

-

<%= article.tags[0] %> / <% 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 %><% } %>

+

<% if (artwork.tags != null) { %><%= artwork.tags[0] %> / <% } %><% 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 %><% } %>

<% } %> diff --git a/frontend/pages/index.ejs b/frontend/pages/index.ejs index b0b1187..988cd0b 100644 --- a/frontend/pages/index.ejs +++ b/frontend/pages/index.ejs @@ -44,7 +44,7 @@

<%= article.title %>

<% if (article.description != null) { %>

<%= article.description.slice(0, 97) %>...

<% } %> -

<%= article.tags[0] %> / <% 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 %><% } %>

+

<% if (article.tags != null) { %><%= article.tags[0] %> / <% } %><% 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 %><% } %>

<% } %> @@ -60,7 +60,7 @@

<%= artwork.title %>

-

<%= artwork.tags[0] %> / <% 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 %><% } %>

+

<% if (artwork.tags != null) { %><%= artwork.tags[0] %> / <% } %><% 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 %><% } %>

<% } %> diff --git a/frontend/pages/search.ejs b/frontend/pages/search.ejs index 34fd9f6..417eee7 100644 --- a/frontend/pages/search.ejs +++ b/frontend/pages/search.ejs @@ -61,7 +61,7 @@

Article: <%= article.title %>

<% if (article.description != null) { %>

<%= article.description.slice(0, 97) %>...

<% } %> -

<%= article.tags[0] %> / <% 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 %><% } %>

+

<% if (tags != null) { %><%= article.tags[0] %> / <% } %><% 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 %><% } %>

<% }); %> @@ -92,7 +92,7 @@

Artwork: <%= artwork.title %>

-

<%= article.tags[0] %> / <% 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 %><% } %>

+

<% if (artwork.tags != null) { %><%= artwork.tags[0] %> / <% } %><% 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 %><% } %>

<% }); %> diff --git a/frontend/pages/tag.ejs b/frontend/pages/tag.ejs index 8f57501..39b6513 100644 --- a/frontend/pages/tag.ejs +++ b/frontend/pages/tag.ejs @@ -3,7 +3,11 @@ <%- 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(); @@ -28,7 +32,7 @@

<%= article.title %>

<%= article.description.slice(0, 97) %>...

-

<%= article.tags[0] %> / <% 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' }) %><% } %>

+

<% if (article.tags != null) { %><%= article.tags[0] %> / <% } %><% 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' }) %><% } %>

<% }); } else { %>No articles found<% } %> diff --git a/frontend/pages/tags.ejs b/frontend/pages/tags.ejs index 0dc2da9..34ae1ac 100644 --- a/frontend/pages/tags.ejs +++ b/frontend/pages/tags.ejs @@ -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) { diff --git a/frontend/partials/suggested.ejs b/frontend/partials/suggested.ejs index 88c46df..4fe6c5d 100644 --- a/frontend/partials/suggested.ejs +++ b/frontend/partials/suggested.ejs @@ -14,7 +14,7 @@ function ifYesterday(date) {

<%= article.title %>

<% if (article.description != null) { %>

<%= article.description.slice(0, 97) %>...

<% } %> -

<%= article.tags[0] %> / <% 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 %><% } %>

+

<% if (article.tags != null) { %><%= article.tags[0] %> / <% } %><% 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 %><% } %>

<% } %>