Skip to content

Commit

Permalink
Add support for selecting the development version separately.
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Aug 13, 2023
1 parent 7ef0bdf commit 55009a8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/InitialGuideSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ function getSelectedGuideVersion(
return undefined;
}
const gameVersion = m[1];
let version: GuideVersion | undefined;
if (gameVersion === "development") {
version = versionIndex.versions.find((v) => v.development);
} else {
version = versionIndex.versions.find((v) => v.gameVersion === gameVersion);
}

const version = versionIndex.versions.find(
(v) => v.gameVersion === gameVersion
);
if (!version) {
console.info("Unknown game version found in fragment: '%s'", gameVersion);
}
Expand Down
15 changes: 13 additions & 2 deletions src/components/version-select/GuideVersionSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,26 @@ type GuideVersionSelectionProps = {
versionIndex: GuideVersionIndex;
};

function getBaseUrl(version: GuideVersion): string {
if (version.development) {
return "#/development/";
} else {
return "#/" + version.gameVersion + "/";
}
}

function GuideVersion({ version }: { version: GuideVersion }) {
const lastUpdate = new Date(version.generated);

return (
<a href={"#/" + version.gameVersion + "/"} className={css.version}>
<a href={getBaseUrl(version)} className={css.version}>
<div className={css.minecraftLogo}>
<span>{version.gameVersion}</span>
</div>
<h2>Applied Energistics 2 {version.modVersion}</h2>
<h2>
Applied Energistics 2 {version.modVersion}
{version.development ? " (Development)" : null}
</h2>
<div>Last Updated: {lastUpdate.toLocaleDateString()}</div>
</a>
);
Expand Down
1 change: 1 addition & 0 deletions src/data/GuideVersionIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type GuideVersion = {
modVersion: string;
generated: number;
url: string;
development: boolean;
};

export type GuideVersionIndex = {
Expand Down
7 changes: 5 additions & 2 deletions worker/update-asset-index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default {
const versions = [];

for (const prefix of response.delimitedPrefixes) {
if (!prefix.match(/^minecraft-([^/]+)\/$/)) {
const devVersion = prefix === "development/";

if (!prefix.match(/^minecraft-([^/]+)\/$/) && !devVersion) {
continue;
}
const indexFile = prefix + 'index.json';
Expand All @@ -31,7 +33,8 @@ export default {
gameVersion: versionIndexContent.gameVersion,
modVersion: versionIndexContent.modVersion,
// This is where the actual data lives in V1 guides
url: 'https://guide-assets.appliedenergistics.org/' + indexFile
url: 'https://guide-assets.appliedenergistics.org/' + indexFile,
development: devVersion
})
} catch (e) {
console.error("Failed to process index file %s", indexFile);
Expand Down

0 comments on commit 55009a8

Please sign in to comment.