Add fallback for missing changelog

pull/73/head
MillenniumEarl 2021-03-04 10:27:34 +01:00
parent 3df82a36b8
commit ed77fa31f5
1 changed files with 11 additions and 9 deletions

View File

@ -231,17 +231,19 @@ function fillWithPostData(hw: HandiWork, elements: IPostElement[]) {
//#region Get the changelog
hw.changelog = [];
const changelogElement = getPostElementByName(elements, "changelog") || getPostElementByName(elements, "change-log");
if (changelogElement) {
const changelogSpoiler = changelogElement?.content.find(el => {
return el.type === "Spoiler" && el.content.length > 0;
});
// Add to the changelog the single spoilers
changelogSpoiler.content.forEach(el => {
changelogSpoiler?.content.forEach(el => {
if (el.text.trim()) hw.changelog.push(el.text);
});
// Add at the ened also the text of the "changelog" element
// Add at the end also the text of the "changelog" element
hw.changelog.push(changelogSpoiler.text);
}
//#endregion Get the changelog
}