From f701846594fbf7c2579285c7e75ac4375676a5b3 Mon Sep 17 00:00:00 2001 From: giovannimanetti11 Date: Tue, 9 Apr 2024 11:40:33 +0000 Subject: [PATCH] Fix APA author format when name is Editors of WikiHerbalist --- inc/js/single-post.js | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/inc/js/single-post.js b/inc/js/single-post.js index 0c9afe4..60d72fb 100755 --- a/inc/js/single-post.js +++ b/inc/js/single-post.js @@ -372,19 +372,25 @@ document.addEventListener('DOMContentLoaded', () => { } // Formats author names according to APA 7th edition + window.formatAPAAuthors = function(authors) { - const authorsArray = authors.split(', ').map((author) => { - const parts = author.split(' '); - const lastName = parts.pop(); - const initials = parts.map(name => `${name.charAt(0)}.`).join(' '); - return `${lastName}, ${initials}`; - }); + if (authors === "Editors of WikiHerbalist" || authors === "WHAdmin") { + return authors; + } + else { + const authorsArray = authors.split(', ').map((author) => { + const parts = author.split(' '); + const lastName = parts.pop(); + const initials = parts.map(name => `${name.charAt(0)}.`).join(' '); + return `${lastName}, ${initials}`; + }); - if (authorsArray.length > 1) { - const lastAuthor = authorsArray.pop(); - return `${authorsArray.join(', ')}, & ${lastAuthor}`; - } else { - return authorsArray[0]; // No need for '&' for a single author + if (authorsArray.length > 1) { + const lastAuthor = authorsArray.pop(); + return `${authorsArray.join(', ')}, & ${lastAuthor}`; + } else { + return authorsArray[0]; // No need for '&' for a single author + } } }