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 //#region Get the changelog
hw.changelog = []; hw.changelog = [];
const changelogElement = getPostElementByName(elements, "changelog") || getPostElementByName(elements, "change-log"); const changelogElement = getPostElementByName(elements, "changelog") || getPostElementByName(elements, "change-log");
if (changelogElement) {
const changelogSpoiler = changelogElement?.content.find(el => { const changelogSpoiler = changelogElement?.content.find(el => {
return el.type === "Spoiler" && el.content.length > 0; return el.type === "Spoiler" && el.content.length > 0;
}); });
// Add to the changelog the single spoilers // Add to the changelog the single spoilers
changelogSpoiler.content.forEach(el => { changelogSpoiler?.content.forEach(el => {
if (el.text.trim()) hw.changelog.push(el.text); 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); hw.changelog.push(changelogSpoiler.text);
}
//#endregion Get the changelog //#endregion Get the changelog
} }