From 9863a49398d56ab156da90d9df49fe5feb311bd0 Mon Sep 17 00:00:00 2001 From: Martin Prokoph Date: Thu, 8 Feb 2024 19:35:10 +0100 Subject: [PATCH] Progress towards publishing --- public/blog/blog-posts.json | 14 ++ src/components/CallToAction.astro | 3 +- src/components/VersionDropdown.astro | 315 +++++++++++++++++++++++++++ src/js/modversion.js | 22 ++ src/pages/midnightlib.astro | 1 + src/pages/wiki/midnightlib.mdx | 19 +- 6 files changed, 368 insertions(+), 6 deletions(-) create mode 100644 public/blog/blog-posts.json create mode 100644 src/components/VersionDropdown.astro create mode 100644 src/js/modversion.js diff --git a/public/blog/blog-posts.json b/public/blog/blog-posts.json new file mode 100644 index 0000000..e92f521 --- /dev/null +++ b/public/blog/blog-posts.json @@ -0,0 +1,14 @@ +[ + { + "userId": 1, + "id": 1, + "title": "So... I have a new website now!", + "body": "After years of just having a lame and half broken, useless site, I proudly present my new website.\nIt is built using Astro to achieve blazing fast performance, eye candy and usefulness at the same time." + }, + { + "userId": 1, + "id": 2, + "title": "qui est esse", + "body": "est rerum tempore vitae\nsequi sint nihil reprehenderit dolor beatae ea dolores neque\nfugiat blanditiis voluptate porro vel nihil molestiae ut reiciendis\nqui aperiam non debitis possimus qui neque nisi nulla" + } +] \ No newline at end of file diff --git a/src/components/CallToAction.astro b/src/components/CallToAction.astro index f0cafb9..2d2c71b 100644 --- a/src/components/CallToAction.astro +++ b/src/components/CallToAction.astro @@ -1,5 +1,5 @@ --- -const { text, url_gh, url_mr, url_cf } = Astro.props +const { text, url_gh, url_mr, url_cf, url_wiki = "" } = Astro.props ---
@@ -9,6 +9,7 @@ const { text, url_gh, url_mr, url_cf } = Astro.props GitHub Modrinth CurseForge + {(url_wiki != '') ? Wiki : ''}
diff --git a/src/components/VersionDropdown.astro b/src/components/VersionDropdown.astro new file mode 100644 index 0000000..3bed3d3 --- /dev/null +++ b/src/components/VersionDropdown.astro @@ -0,0 +1,315 @@ +--- +import { loaderList, selectedLoader, selectedVersion } from '../js/modversion.js' +--- + +
+
+
+ +
+
+
+ + + + diff --git a/src/js/modversion.js b/src/js/modversion.js new file mode 100644 index 0000000..3d16986 --- /dev/null +++ b/src/js/modversion.js @@ -0,0 +1,22 @@ +export const modInfo = await fetch('https://api.modrinth.com/v2/project/midnightlib/version').then((response) => response.json()) +export const loaderList = ['fabric', 'quilt', 'forge', 'neoforge']; +var finishedArray = modInfo.reduce(function(map, value) { + value.game_versions.forEach(version => { + value.loaders.forEach(loader => { + const loaderAndVersion = loader + "+" +version; + if (Object.values(map).includes(loaderAndVersion)) { + console.log("return") + return; + } + if (value.featured) map[loaderAndVersion] = value.id; + }); + }); + return map; +}, {}); +console.log(finishedArray); +export var selectedLoader = "fabric"; +export var selectedVersion = "1.20.4"; +var resultingVersionID = await finishedArray[selectedLoader + "+" + selectedVersion]; +export var resultingVersion = "Could not find the latest version!"; +resultingVersion = modInfo.find((info) => info.id == resultingVersionID).version_number; +{console.log(resultingVersion)} \ No newline at end of file diff --git a/src/pages/midnightlib.astro b/src/pages/midnightlib.astro index acb716c..e23fa38 100644 --- a/src/pages/midnightlib.astro +++ b/src/pages/midnightlib.astro @@ -50,5 +50,6 @@ import ContentMedia from '../components/ContentMedia.astro' url_gh="https://github.com/TeamMidnightDust/MidnightLib" url_mr="https://modrinth.com/mod/midnightlib" url_cf="https://www.curseforge.com/minecraft/mc-mods/midnightlib" + url_wiki="/wiki/midnightlib" /> diff --git a/src/pages/wiki/midnightlib.mdx b/src/pages/wiki/midnightlib.mdx index d4a243b..3f46da0 100644 --- a/src/pages/wiki/midnightlib.mdx +++ b/src/pages/wiki/midnightlib.mdx @@ -3,8 +3,10 @@ layout: ../../layouts/MarkdownLayout.astro title: MidnightLib Wiki --- +import VersionDropdown from '../../components/VersionDropdown.astro' import { Icon } from 'astro-icon/components' import { Notification } from 'accessible-astro-components' +import { resultingVersion } from '../../js/modversion.js' # MidnightLib Wiki @@ -12,6 +14,12 @@ Welcome to the MidnightLib wiki. Thanks for showing interest in our library! This documentation aims to show you how to use the config system and the other features the library provides. Use the tabs on the right side to switch between the different pages. +Explore MidnightLib's features on this page! + + +Get to know the features + + To use the library in your mods, just edit `build.gradle` and `gradle.properties` as seen below: ### `build.gradle` ```java @@ -26,19 +34,20 @@ dependencies { modImplementation include "maven.modrinth:midnightlib:${project.midnightlib_version}" } ``` -### `gradle.properties` -```js -midnightlib_version=1.5.3-fabric -``` +### `gradle.properties` + +{
midnightlib_version = {resultingVersion}
} +

Info: You should always pick the version that suits your modloader and Minecraft version best. + The version selector is currently still WIP. Find all available versions on [Modrinth](https://www.modrinth.com/mod/midnightlib/versions)

-### `MidnightConfigExample.java` +### `YourConfigClass.java` To get started with implementing the config, you must create a public class that extends MidnightConfig. In this class, your variables can be stored and accessed. Here you can see the contents of an example config class: ```java