Skip to content

Commit 63cac24

Browse files
committed
Add reivison number as url in version box
1 parent 229325f commit 63cac24

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

web/src/pages/reference/[func].astro

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
33
import { getCollection } from 'astro:content';
44
import { getFunctionInfo, parseFunctionSyntaxes, getFixedStaticOOPClass } from '@src/utils/functions';
5-
import { renderInlineMarkdown, getSeeAlsoLinksForItem, extractVersion, isVersionLE } from '@src/utils/general';
5+
import { renderInlineMarkdown, getSeeAlsoLinksForItem, extractVersion, isVersionLE, renderRevisionLink } from '@src/utils/general';
66
import fs from "fs";
77
import path from "path";
88
import { Code } from '@astrojs/starlight/components';
@@ -59,6 +59,7 @@ if (func.data.server && func.data.server.examples) {
5959
...func.data.server.examples.map((ex: any) => ({ ...ex, side: 'server' })),
6060
];
6161
}
62+
6263
funcExamples = funcExamples.map((example: any) => {
6364
try {
6465
const luaCode = fs.readFileSync(path.resolve(`${funcPath}`, example.path), "utf8");
@@ -134,19 +135,23 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
134135
<div class="added-updated-description-box-header">
135136
<p>
136137
{showRemoved ? (
137-
<>
138-
<strong>Before</strong> {removedVersionRaw}
139-
</>
138+
<>
139+
<strong>Before</strong> <span set:html={renderRevisionLink(removedVersionRaw)} />
140+
</>
140141
) : (
141-
<>
142-
{showUpdated && (
143-
<strong>Updated in {updatedVersionRaw}</strong>
144-
)}
145-
{showUpdated && showAdded && ' | '}
146-
{showAdded && (
147-
<strong>Added in {addedVersionRaw}</strong>
148-
)}
149-
</>
142+
<>
143+
{showUpdated && (
144+
<strong>
145+
Updated in <span set:html={renderRevisionLink(updatedVersionRaw)} />
146+
</strong>
147+
)}
148+
{showUpdated && showAdded && ' | '}
149+
{showAdded && (
150+
<strong>
151+
Added in <span set:html={renderRevisionLink(addedVersionRaw)} />
152+
</strong>
153+
)}
154+
</>
150155
)}
151156
</p>
152157
</div>

web/src/utils/general.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,15 @@ export function isVersionLE(v: string, ref: string): boolean {
249249
if (a1 !== b1) return a1 < b1;
250250
if (a2 !== b2) return a2 < b2;
251251
return a3 <= b3;
252+
}
253+
254+
export function renderRevisionLink(versionRaw: string) {
255+
const match = versionRaw.match(/r(\d+)/);
256+
if (!match) return versionRaw;
257+
258+
const revisionNumber = match[1];
259+
const beforeRevision = versionRaw.slice(0, match.index);
260+
const url = `https://buildinfo.mtasa.com/?Author=&Branch=&Revision=${revisionNumber}`;
261+
262+
return `${beforeRevision}<a href="${url}" target="_blank" rel="noopener noreferrer">r${revisionNumber}</a>`;
252263
}

0 commit comments

Comments
 (0)