Minor changes

2.0.0-ts
MillenniumEarl 2021-03-17 12:50:24 +01:00
parent 3b911669fe
commit 5309e69c9b
1 changed files with 13 additions and 8 deletions

View File

@ -207,7 +207,10 @@ function fillWithPostData(hw: HandiWork, elements: IPostElement[]) {
// Get the genres // Get the genres
const genre = getPostElementByName(elements, "genre")?.content.shift()?.text; const genre = getPostElementByName(elements, "genre")?.content.shift()?.text;
hw.genre = genre?.split(",").map((s) => s.trim()); hw.genre = genre
?.split(",")
.map((s) => s.trim())
.filter((s) => s !== "");
// Get the cover // Get the cover
const cover = getPostElementByName(elements, "overview")?.content.find( const cover = getPostElementByName(elements, "overview")?.content.find(
@ -245,15 +248,17 @@ function fillWithPostData(hw: HandiWork, elements: IPostElement[]) {
hw.changelog = []; hw.changelog = [];
const changelogElement = const changelogElement =
getPostElementByName(elements, "changelog") || getPostElementByName(elements, "change-log"); getPostElementByName(elements, "changelog") || getPostElementByName(elements, "change-log");
if (changelogElement) {
const changelogSpoiler = changelogElement?.content.find((el) => { if (changelogElement?.content) {
return el.type === "Spoiler" && el.content.length > 0; const changelogSpoiler = changelogElement.content.find(
}); (el) => 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) => { const spoilers = changelogSpoiler.content
if (el.text.trim()) hw.changelog.push(el.text); .filter((e) => e.text.trim() !== "")
}); .map((e) => e.text);
hw.changelog.push(...spoilers);
// Add at the end 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);