Skip to content

Commit 4a9fc82

Browse files
authored
Add changelog property (#18)
1 parent 6f73f09 commit 4a9fc82

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

schemas/common-defs.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ $defs:
3535
needs_checking:
3636
type: string
3737
description: Describe why the item needs checking by another person. What's problematic?
38+
changelog:
39+
type: array
40+
description: A chronological list of changes related to this item.
41+
items:
42+
type: object
43+
required:
44+
- version
45+
- description
46+
properties:
47+
version:
48+
type: string
49+
description: Version in which the change was introduced.
50+
description:
51+
type: string
52+
description: Description of what changed.
3853

3954
preview_images:
4055
type: array
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
interface ChangelogEntry {
3+
version: string;
4+
description: string;
5+
}
6+
7+
interface Props {
8+
entries: ChangelogEntry[];
9+
}
10+
11+
const { entries } = Astro.props;
12+
---
13+
14+
{entries.length > 0 && (
15+
<div class="changelog-section">
16+
<h4>Changelog</h4>
17+
<div class="changelog-list">
18+
{entries.map(entry => (
19+
<li>
20+
<span class="changelog-version">{entry.version}</span>
21+
<span class="changelog-description">{entry.description}</span>
22+
</li>
23+
))}
24+
</div>
25+
</div>
26+
)}
27+
28+
<style>
29+
.changelog-list {
30+
background-color: var(--sl-color-bg-nav);
31+
border-left: 4px solid var(--sl-color-gray-5);
32+
border-radius: 8px;
33+
padding: 1rem 1.25rem;
34+
margin-bottom: 1.5rem;
35+
color: var(--sl-color-text);
36+
list-style: none;
37+
}
38+
39+
.changelog-version {
40+
font-weight: bold;
41+
color: var(--sl-color-orange-high);
42+
display: block;
43+
}
44+
45+
.changelog-description {
46+
display: block;
47+
margin-left: 0.5rem;
48+
}
49+
</style>

web/src/pages/[func].astro

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import type { NotesType } from '@src/utils/types';
1414
import SeeAlsoSection from '@src/components/SeeAlsoSection.astro';
1515
import CodeExamplesSection from '@src/components/CodeExamplesSection.astro';
1616
17+
import ChangelogList from '@src/components/ChangelogList.astro';
18+
1719
export async function getStaticPaths() {
1820
const functions = await getCollection('functions');
1921
return functions.map(func => ({
@@ -56,6 +58,9 @@ if (Array.isArray(funcInfo.notes) && funcInfo.notes.length > 0) {
5658
notesContent = funcInfo.notes;
5759
}
5860
61+
const metaArray = func.data[funcInfo.type]?.meta ?? [];
62+
const changelogEntries = metaArray.find(m => m.changelog)?.changelog ?? [];
63+
5964
let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
6065
6166
---
@@ -175,6 +180,8 @@ let funcSyntaxes = parseFunctionSyntaxes(func.id, func.data);
175180

176181
<CodeExamplesSection codeExamples={funcExamples} />
177182

183+
<ChangelogList entries={changelogEntries} />
184+
178185
<SeeAlsoSection seeAlsoLinks={getSeeAlsoLinksForItem(func)} currentId={func.id} />
179186
</StarlightPage>
180187
</div>

web/src/styles/custom.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
.function-syntax,
1818
.function-oop,
1919
.notes-section,
20-
.examples-section {
20+
.examples-section,
21+
.changelog-section {
2122
margin-top: 1.5rem;
2223
margin-bottom: 1.5rem;
2324
}

0 commit comments

Comments
 (0)