changelogManager: refactor

This commit is contained in:
dumbmoron 2024-01-14 23:52:46 +00:00
parent 7a7343bf13
commit 2d1c1782de
No known key found for this signature in database
GPG key ID: C59997C76C6A8E5F

View file

@ -5,33 +5,35 @@ let changelog = loadJSON('./src/modules/changelog/changelog.json')
export default function(string) { export default function(string) {
try { try {
const currentChangelog = changelog.current;
switch (string) { switch (string) {
case "version": case "version":
return `<span class="text-backdrop changelog-tag-version">v.${changelog["current"]["version"]}</span>${ return `<span class="text-backdrop changelog-tag-version">v.${currentChangelog.version}</span>${
changelog["current"]["date"] ? `<span class="changelog-tag-date">· ${changelog["current"]["date"]}</span>` : '' currentChangelog.date ? `<span class="changelog-tag-date">· ${currentChangelog.date}</span>` : ''
}` }`
case "title": case "title":
return replaceBase(changelog["current"]["title"]); return replaceBase(currentChangelog.title);
case "banner": case "banner":
return changelog["current"]["banner"] ? { const currentBanner = changelog.current.banner;
url: `updateBanners/${changelog["current"]["banner"]["file"]}`, return currentBanner ? {
width: changelog["current"]["banner"]["width"], ...currentBanner,
height: changelog["current"]["banner"]["height"] url: `updateBanners/${currentBanner.file}`
} : false; } : false;
case "content": case "content":
return replaceBase(changelog["current"]["content"]); return replaceBase(currentChangelog.content);
case "history": case "history":
return changelog["history"].map((i) => { return changelog.history.map((log) => {
const banner = log.banner;
return { return {
title: replaceBase(i["title"]), title: replaceBase(log.title),
version: `<span class="text-backdrop changelog-tag-version">v.${i["version"]}</span>${ version: `<span class="text-backdrop changelog-tag-version">v.${log.version}</span>${
i["date"] ? `<span class="changelog-tag-date">· ${i["date"]}</span>` : '' log.date ? `<span class="changelog-tag-date">· ${log.date}</span>` : ''
}`, }`,
content: replaceBase(i["content"]), content: replaceBase(log.content),
banner: i["banner"] ? { banner: banner ? {
url: `updateBanners/${i["banner"]["file"]}`, ...banner,
width: i["banner"]["width"], url: `updateBanners/${banner.file}`
height: i["banner"]["height"]
} : false, } : false,
} }
}); });