22import StarlightPage from ' @astrojs/starlight/components/StarlightPage.astro' ;
33import { getCollection } from ' astro:content' ;
44import { getFunctionInfo , parseFunctionSyntaxes , getFixedStaticOOPClass } from ' @src/utils/functions' ;
5- import { renderInlineMarkdown , getSeeAlsoLinksForItem } from ' @src/utils/general' ;
5+ import { renderInlineMarkdown , getSeeAlsoLinksForItem , extractVersion , isVersionLE } from ' @src/utils/general' ;
66import fs from " fs" ;
77import path from " path" ;
88import { Code } from ' @astrojs/starlight/components' ;
9+ import { MTA_CURRENT_VERSION } from ' @src/content.constants' ;
910
1011import NoteBox from ' @src/components/NoteBox.astro' ;
1112import type { NotesType } from ' @src/utils/types' ;
@@ -80,6 +81,33 @@ const needsChecking = metaArray.find(m => m.needs_checking)?.needs_checking ?? u
8081let funcSyntaxes = parseFunctionSyntaxes (func .id , func .data );
8182---
8283
84+ <style >
85+ .added-updated-description-box {
86+ display: flex;
87+ flex-direction: column;
88+ background-color: var(--sl-color-bg-nav);
89+ border-radius: 10px;
90+ }
91+
92+ .added-updated-description-box-header {
93+ padding: 0.5rem 1.0rem;
94+ color: var(--sl-color-text);
95+ background-color: var(--sl-color-gray-5);
96+ border-radius: 10px 10px 0 0;
97+ }
98+
99+ .added-updated-description-box.removed-box .added-updated-description-box-header {
100+ background-color: var(--color-type-client-background-high);
101+ color: #f85c50;
102+ font-weight: bold;
103+ }
104+
105+ .added-updated-description-box-body {
106+ margin: 0;
107+ padding: 1rem 1rem;
108+ }
109+ </style >
110+
83111<div class ={ " show-type-badge-" + funcType } >
84112 <StarlightPage frontmatter ={ {
85113 template: ' doc' ,
@@ -100,7 +128,71 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
100128 )}
101129
102130 <!-- Description -->
103- <ItemDescription description ={ funcInfo .description } incomplete ={ funcInfo .incomplete } />
131+ { funcInfo .version ? (() => {
132+ const CURRENT = MTA_CURRENT_VERSION .full ;
133+
134+ const addedVersionRaw = funcInfo .version .added || " " ;
135+ const updatedVersionRaw = funcInfo .version .updated || " " ;
136+ const removedVersionRaw = funcInfo .version .removed || " " ;
137+
138+ const addedVersion = extractVersion (addedVersionRaw );
139+ const updatedVersion = extractVersion (updatedVersionRaw );
140+
141+ const showAdded = !! addedVersion && isVersionLE (CURRENT , addedVersion );
142+ const showUpdated = !! updatedVersion && isVersionLE (CURRENT , updatedVersion );
143+ const showRemoved = !! removedVersionRaw ;
144+
145+ // Jeśli nie ma nic do pokazania
146+ if (! showRemoved && ! showAdded && ! showUpdated ) {
147+ return (
148+ <ItemDescription
149+ description = { funcInfo .description }
150+ incomplete = { funcInfo .incomplete }
151+ />
152+ );
153+ }
154+
155+ return (
156+ <div
157+ class = {
158+ " added-updated-description-box" +
159+ (showRemoved ? " removed-box" : " " )
160+ }
161+ >
162+ <div class = " added-updated-description-box-header" >
163+ <p >
164+ { showRemoved ? (
165+ <>
166+ <strong >Before</strong > { removedVersionRaw }
167+ </>
168+ ) : (
169+ <>
170+ { showUpdated && (
171+ <strong >Updated in { updatedVersionRaw } </strong >
172+ )}
173+ { showUpdated && showAdded && ' | ' }
174+ { showAdded && (
175+ <strong >Added in { addedVersionRaw } </strong >
176+ )}
177+ </>
178+ )}
179+ </p >
180+ </div >
181+
182+ <div class = " added-updated-description-box-body" >
183+ <ItemDescription
184+ description = { funcInfo .description }
185+ incomplete = { funcInfo .incomplete }
186+ />
187+ </div >
188+ </div >
189+ );
190+ })() : (
191+ <ItemDescription
192+ description = { funcInfo .description }
193+ incomplete = { funcInfo .incomplete }
194+ />
195+ )}
104196
105197 <!-- Notes -->
106198 { notesContent .length > 0 && (
0 commit comments