Skip to content

Commit ed226e3

Browse files
authored
Merge pull request #21809 from AnnsAnns/improve_changelog
Starlight/Changelog: Add direct Github link support
2 parents 380dc68 + c0f3ace commit ed226e3

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ indent_size = 2
1414
tab_size = 2
1515
trim_trailing_whitespace = true
1616
insert_final_newline = true
17+
18+
[*{.astro, .js, .ts, .mjs, .json}]
19+
indent_style = space
20+
indent_size = 2
21+
trim_trailing_whitespace = true
22+
insert_final_newline = true

doc/starlight/src/content.config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ export function changelogLoader(): Loader {
9797
.slice(currentReleaseHeadingIndex + 1, index)
9898
.join("\n");
9999

100+
// Replace #ID entries with links to GitHub issues
101+
// Github treats both PRs and Issues the same way regarding links
102+
const contentWithGithubLinks = currentReleaseContent.replace(
103+
/#(\d+)/g,
104+
"[#$1](https://github.com/RIOT-OS/RIOT/issues/$1)",
105+
);
106+
100107
// Add entry to content collection
101108
context.store.set({
102109
id: slug,
@@ -108,9 +115,9 @@ export function changelogLoader(): Loader {
108115
codeName: codeName,
109116
slug: slug,
110117
date: date,
111-
markdown: currentReleaseContent,
118+
markdown: contentWithGithubLinks,
112119
},
113-
rendered: await context.renderMarkdown(currentReleaseContent),
120+
rendered: await context.renderMarkdown(contentWithGithubLinks),
114121
});
115122
}
116123

doc/starlight/src/pages/changelog/[version].astro

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
import StarlightPage from "@astrojs/starlight/components/StarlightPage.astro";
3+
import { LinkCard } from "@astrojs/starlight/components";
34
import { getCollection, render } from "astro:content";
45
56
export async function getStaticPaths() {
@@ -26,5 +27,11 @@ const { Content, headings } = await render(entry);
2627
pagefind: false, // We don't want to pollute our search with release-notes entries
2728
}}
2829
headings={headings}
29-
><Content />
30+
>
31+
<LinkCard
32+
title="View on GitHub"
33+
href={`https://github.com/RIOT-OS/RIOT/releases/tag/${entry.data.slug.replaceAll("-", ".")}`}
34+
description="The changelog can also be found on GitHub."
35+
/>
36+
<Content />
3037
</StarlightPage>

0 commit comments

Comments
 (0)