From b314c257e5ede3c620539ffd3a294130752b074b Mon Sep 17 00:00:00 2001 From: Leo dev Date: Fri, 18 Apr 2025 16:59:50 +0200 Subject: [PATCH] fix --- public/news-md/0.md | 22 ++++++++++++++++++++++ src/lib/newsParser.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 public/news-md/0.md create mode 100644 src/lib/newsParser.ts diff --git a/public/news-md/0.md b/public/news-md/0.md new file mode 100644 index 0000000..3b683ca --- /dev/null +++ b/public/news-md/0.md @@ -0,0 +1,22 @@ +--- +authors: Kleo +title: Refactoring +description: The current codebase isn't practical, so we are refractoring it +image: https://preview.redd.it/axscigvvfik71.png?auto=webp&s=ddd458f865c6f50d21a66fe76dc12a07c8b1e198 +date: 2025-04-18 +tags: development, news +--- +Due to Minecraft's nature of refactors for the past decade (which is normal for all apps), we have decided to refactor the codebase to make it more maintainable and practical. This will also take us in other versions of Minecraft. + +We will be working on this in the next few weeks trying to improve both the codebase and the user experience. + +## Goals +- 📖 Document every change done to the code, both in discord and in the github wiki, this is mandatory. +- 🧩 Separate as much code from Minecraft as possible (abstractions), important for adding other versions. +- 🎨 Make the UI as customizable as possible, good for user experience, we should keep this in mind. + +For updates, check out our [Discord](https://discord.gg/HFRsNxfCqT) or [GitHub issue](https://github.com/saturnclientmc/saturnclient/issues/1) + +--- + +Credits to [Electronic_Sample_96](https://www.reddit.com/r/Minecraft/comments/pejvos/an_ultrawide_wallpaper_on_minecraft_2560_x_1080/) for the image diff --git a/src/lib/newsParser.ts b/src/lib/newsParser.ts new file mode 100644 index 0000000..2188fc3 --- /dev/null +++ b/src/lib/newsParser.ts @@ -0,0 +1,40 @@ + +import smartSplit from "./smartSplit"; + +export interface News { + authors: string[]; + title: string; + description: string; + image: string; + date: string; + id: string; +} + +export function parseNews(news: string, id: string): News { + const content = news.split("---", 2)[1]; + + const params: News = { + authors: [], + title: "Undefined title", + description: "", + image: "/background.png", + date: "Undefined date", + id, + }; + + content.split("\n").forEach((v) => { + const [key, value] = smartSplit(v, ":", 2).map((v) => v.trim()); + if (key === "authors") { + params.authors = value.split(",").map((v) => v.trim()); + } else if ( + key === "title" || + key === "description" || + key === "image" || + key === "date" + ) { + params[key] = value; + } + }); + + return params; + } \ No newline at end of file