Fix items with no URL in socials

This commit is contained in:
bingus_violet 2024-08-08 10:09:21 -05:00
parent d379475b45
commit cefb365f66

View file

@ -51,6 +51,14 @@ function firstToUpper(str) {
return str.charAt(0).toUpperCase() + str.slice(1) return str.charAt(0).toUpperCase() + str.slice(1)
} }
function onlyIfExists(string, check) {
if (check) {
return string
} else {
return ""
}
}
function makeHtmlSafe(str) { function makeHtmlSafe(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
} }
@ -299,9 +307,8 @@ function converter(html, dynamic = true) {
for (var x = 0; x < sitesTable.length; x++) { for (var x = 0; x < sitesTable.length; x++) {
var siteName = sitesTable[x] var siteName = sitesTable[x]
var siteData = sites[siteName] var siteData = sites[siteName]
if (siteData.url) { html += `<a class="chip" ${onlyIfExists(`href="${siteData.url}"`, siteData.url)}>${siteName}: ${siteData.name.replaceAll("Violet", "{Violet}")}</a>`
html += `<a class="chip" href="${siteData.url}">${siteName}: ${siteData.name.replaceAll("Violet", "{Violet}")}</a>`
}
} }
html += "</div></div>" html += "</div></div>"
} }