Skip to content

Commit 2a418cd

Browse files
Dynamic release notes rendering (#1136)
* Dynamic release notes rendering * feat: style fetched data * chore: refactor styling * chore: align text * feat: add lab version fetching * fix: version filtering --------- Co-authored-by: AlexIchenskiy <[email protected]>
1 parent 6c2b867 commit 2a418cd

File tree

3 files changed

+87
-26
lines changed

3 files changed

+87
-26
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { MDXProvider } from "nextra/mdx";
2+
import { useEffect, useState } from "react";
3+
4+
const sectionEmojiByType = {
5+
'new': '✨',
6+
'improvement': '🛠️',
7+
'fix': '🐞',
8+
}
9+
10+
const sectionNameByType = {
11+
'new': 'New features',
12+
'improvement': 'Improvements',
13+
'fix': 'Bug fixes',
14+
}
15+
16+
// version should be a single string (e.g. '2.1.0', '3.1.2' etc.)
17+
export default function LabReleasesClient({ version }) {
18+
const [data, setData] = useState([]);
19+
const [loading, setLoading] = useState(true);
20+
21+
useEffect(() => {
22+
// Fetch data from the API
23+
const fetchData = async () => {
24+
try {
25+
const res = await fetch("https://lab.memgraph.com/public/versions");
26+
const json = await res.json();
27+
setData(json.items || []); // Ensure data is always an array
28+
} catch (error) {
29+
setData([]);
30+
setLoading(false);
31+
} finally {
32+
setLoading(false);
33+
}
34+
};
35+
36+
fetchData();
37+
}, []);
38+
39+
if (loading) {
40+
return <p>Loading release notes...</p>;
41+
}
42+
43+
if (!Array.isArray(data) || data.length === 0) {
44+
return <>Could not load release notes for version {version}.</>;
45+
}
46+
47+
const filteredDataArray = data.filter(item => item.version === version);
48+
49+
if (filteredDataArray.length === 0) {
50+
return <p>No release notes found for version {version}.</p>;
51+
}
52+
53+
const filteredData = filteredDataArray[0];
54+
55+
return (
56+
<div>
57+
{filteredData.sections.map((section, index) => (
58+
<div key={index}>
59+
<h4 className="custom-header">{sectionEmojiByType[section.type.toLowerCase()] || ''} {sectionNameByType[section.type.toLowerCase()] || ''}</h4>
60+
<ul className="list-disc ltr:ml-6 rtl:mr-6">
61+
{section.items.map((itemGroup, i) => (
62+
<li className={`my-3 ${i === 0 ? 'mt-6' : ''}`} key={i}>
63+
{itemGroup.map((entry, j) => (
64+
<span key={j}>
65+
{entry.type === "code" ? <code>{entry.value}</code> : entry.value}
66+
</span>
67+
))}
68+
</li>
69+
))}
70+
</ul>
71+
</div>
72+
))}
73+
</div>
74+
);
75+
}

pages/release-notes.mdx

+4-26
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ description: Stay up-to-date with the latest features and updates within Memgrap
55

66
import { Callout } from 'nextra/components'
77
import { Cards } from 'nextra/components'
8+
import { useMemo } from 'react';
9+
import LabReleasesClient from "/components/release-notes/LabReleasesClient";
10+
811

912
# Release notes
1013

@@ -284,32 +287,7 @@ updated.
284287

285288
### Lab v3.1.0 - Mar 12th, 2025
286289

287-
{<h4 className="custom-header">✨ New features</h4>}
288-
289-
- The query summary now shows the number of
290-
hops in your Cypher query.
291-
- You can delete all or specific recent
292-
connections from the login page.
293-
294-
{<h4 className="custom-header">🛠️ Improvements</h4>}
295-
296-
- Username and password authentication is
297-
always visible when connecting to a Memgraph
298-
HA cluster.
299-
- Screenshot size is reduced when saving
300-
Graph Style Script (GSS) to remote storage,
301-
preventing request and storage limit issues.
302-
303-
{<h4 className="custom-header">🐞 Bug fixes</h4>}
304-
305-
- Vector indexes in `cypherl` import files and
306-
multiple queries are now handled correctly in
307-
separate transactions.
308-
- Fixed an issue where Lab couldn't find query
309-
module names with mixed case.
310-
- Fixed an issue where connecting to a custom
311-
database in an HA cluster resulted in an "Unknown
312-
database name" error.
290+
<LabReleasesClient version="3.1.0" />
313291

314292
## Previous releases
315293

utils/fetchData.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export async function fetchData() {
2+
const res = await fetch("https://lab.memgraph.com/public/versions");
3+
const json = await res.json();
4+
5+
console.log("API Response:", json); // ✅ Debugging API response
6+
7+
return json.items || []; // Extract the 'items' array or return an empty array
8+
}

0 commit comments

Comments
 (0)